#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
using db = double;
using str = string; // yay python!

using pi = pair<int,int>;
using pl = pair<ll,ll>;
using pd = pair<db,db>;

using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<ll>;
using vd = vector<db>;
using vs = vector<str>;
using vpi = vector<pi>;
using vpl = vector<pl>;
using vpd = vector<pd>;

#define tcT template<class T
// ^ lol this makes everything look weird but I'll try it
tcT> using V = vector<T>;
tcT, size_t SZ> using AR = array<T,SZ>;

// pairs
#define mp make_pair
#define f first
#define s second

// vectors
#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sor(x) sort(all(x))
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound

// loops
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)

const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5;
const ll INF = 1e18; // not too close to LLONG_MAX
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; // for every grid problem!!
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

// helper funcs
constexpr int pct(int x) { return __builtin_popcount(x); } // # of bits set
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x))
ll cdiv(ll a, ll b) { return a/b+((a^b)>0&&a%b); } // divide a by b rounded up
ll fdiv(ll a, ll b) { return a/b-((a^b)<0&&a%b); } // divide a by b rounded down

tcT> bool ckmin(T& a, const T& b) {
	return b < a ? a = b, 1 : 0; } // set a = min(a,b)
tcT> bool ckmax(T& a, const T& b) {
	return a < b ? a = b, 1 : 0; }

#define tcTU tcT, class U
tcTU> T fstTrue(T lo, T hi, U f) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true
		T mid = lo+(hi-lo)/2;
		f(mid) ? hi = mid : lo = mid+1;
	}
	return lo;
}
tcTU> T lstTrue(T lo, T hi, U f) {
	lo --; assert(lo <= hi); // assuming f is decreasing
	while (lo < hi) { // find first index such that f is true
		T mid = lo+(hi-lo+1)/2;
		f(mid) ? lo = mid : hi = mid-1;
	}
	return lo;
}
tcT> void remDup(vector<T>& v) { // sort and remove duplicates
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
tcTU> void erase(T& t, const U& u) { // don't erase
	auto it = t.find(u); assert(it != end(t));
	t.erase(u); } // element that doesn't exist from (multi)set

// INPUT
#define tcTUU tcT, class ...U
tcT> void re(complex<T>& c);
tcTU> void re(pair<T,U>& p);
tcT> void re(vector<T>& v);
tcT, size_t SZ> void re(AR<T,SZ>& a);

tcT> void re(T& x) { cin >> x; }
void re(db& d) { str t; re(t); d = stod(t); }
void re(ld& d) { str t; re(t); d = stold(t); }
tcTUU> void re(T& t, U&... u) { re(t); re(u...); }

tcT> void re(complex<T>& c) { T a,b; re(a,b); c = {a,b}; }
tcTU> void re(pair<T,U>& p) { re(p.f,p.s); }
tcT> void re(vector<T>& x) { trav(a,x) re(a); }
tcT, size_t SZ> void re(AR<T,SZ>& x) { trav(a,x) re(a); }

// TO_STRING
#define ts to_string
str ts(char c) { return str(1,c); }
str ts(const char* s) { return (str)s; }
str ts(str s) { return s; }
str ts(bool b) {
	#ifdef LOCAL
		return b ? "true" : "false";
	#else
		return ts((int)b);
	#endif
}
tcT> str ts(complex<T> c) {
	stringstream ss; ss << c; return ss.str(); }
str ts(vector<bool> v) {
	str res = "{"; F0R(i,sz(v)) res += char('0'+v[i]);
	res += "}"; return res; }
template<size_t SZ> str ts(bitset<SZ> b) {
	str res = ""; F0R(i,SZ) res += char('0'+b[i]);
	return res; }
tcTU> str ts(pair<T,U> p);
tcT> str ts(T v) { // containers with begin(), end()
	#ifdef LOCAL
		bool fst = 1; str res = "{";
		for (const auto& x: v) {
			if (!fst) res += ", ";
			fst = 0; res += ts(x);
		}
		res += "}"; return res;
	#else
		bool fst = 1; str res = "";
		for (const auto& x: v) {
			if (!fst) res += " ";
			fst = 0; res += ts(x);
		}
		return res;

	#endif
}
tcTU> str ts(pair<T,U> p) {
	#ifdef LOCAL
		return "("+ts(p.f)+", "+ts(p.s)+")";
	#else
		return ts(p.f)+" "+ts(p.s);
	#endif
}

// OUTPUT
tcT> void pr(T x) { cout << ts(x); }
tcTUU> void pr(const T& t, const U&... u) {
	pr(t); pr(u...); }
void ps() { pr("\n"); } // print w/ spaces
tcTUU> void ps(const T& t, const U&... u) {
	pr(t); if (sizeof...(u)) pr(" "); ps(u...); }

// DEBUG
void DBG() { cerr << "]" << endl; }
tcTUU> void DBG(const T& t, const U&... u) {
	cerr << ts(t); if (sizeof...(u)) cerr << ", ";
	DBG(u...); }
#ifdef LOCAL // compile with -DLOCAL, chk -> fake assert
	#define dbg(...) cerr << "Line(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
	#define chk(...) if (!(__VA_ARGS__)) cerr << "Line(" << __LINE__ << ") -> function(" \
		 << __FUNCTION__  << ") -> CHK FAILED: (" << #__VA_ARGS__ << ")" << "\n", exit(0);
#else
	#define dbg(...) 0
	#define chk(...) 0
#endif

// FILE I/O
void setIn(str s) { freopen(s.c_str(),"r",stdin); }
void setOut(str s) { freopen(s.c_str(),"w",stdout); }
void unsyncIO() { cin.tie(0)->sync_with_stdio(0); }
void setIO(str s = "") {
	unsyncIO();
	// cin.exceptions(cin.failbit);
	// throws exception when do smth illegal
	// ex. try to read letter into int
	if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

struct MCMF {
	using F = ll; using C = ll; // flow type, cost type
	struct Edge { int to, rev; F flo, cap; C cost; int id; };
	int N; V<C> p, dist; vpi pre; V<V<Edge>> adj;
	void init(int _N) { N = _N;
		p.rsz(N), adj.rsz(N), dist.rsz(N), pre.rsz(N); }
	void ae(int u, int v, F cap, C cost, int id) { assert(cap >= 0);
		adj[u].pb({v,sz(adj[v]),0,cap,cost,id});
		adj[v].pb({u,sz(adj[u])-1,0,0,-cost,-1});
	} // use asserts, don't try smth dumb
	bool path(int s, int t) { // find lowest cost path to send flow through
		const C inf = numeric_limits<C>::max(); dist.assign(N,inf);
		using T = pair<C,int>; priority_queue<T,vector<T>,greater<T>> todo;
		todo.push({dist[s] = 0,s});
		while (sz(todo)) { // Dijkstra
			T x = todo.top(); todo.pop(); if (x.f > dist[x.s]) continue;
			trav(e,adj[x.s]) { // all weights should be non-negative
				if (e.flo < e.cap && ckmin(dist[e.to],x.f+e.cost+p[x.s]-p[e.to]))
					pre[e.to] = {x.s,e.rev}, todo.push({dist[e.to],e.to});
			}
		} // if costs are doubles, add some EPS so you
		// don't traverse ~0-weight cycle repeatedly
		return dist[t] != inf; // return flow
	}
	pair<F,C> calc(int s, int t) { assert(s != t);
		F0R(_,N) F0R(i,N) trav(e,adj[i]) // Bellman-Ford
			if (e.cap) ckmin(p[e.to],p[i]+e.cost);
		dbg("FINISHED BELLMAN");
		F totFlow = 0; C totCost = 0;
		while (path(s,t)) { // p -> potentials for Dijkstra
			dbg("PATH",s,t);
			F0R(i,N) p[i] += dist[i]; // don't matter for unreachable nodes
			F df = numeric_limits<F>::max();
			for (int x = t; x != s; x = pre[x].f) {
				Edge& e = adj[pre[x].f][adj[x][pre[x].s].rev];
				ckmin(df,e.cap-e.flo); }
			totFlow += df; totCost += (p[t]-p[s])*df;
			for (int x = t; x != s; x = pre[x].f) {
				adj[pre[x].f][adj[x][pre[x].s].rev].flo += df;
				adj[x][pre[x].s].flo -= df; }
		} // get max flow you can send along path
		return {totFlow,totCost};
	}
};

int n,k;
MCMF m;

vector<array<int,3>> compress(vector<array<int,3>> v) {
    map<int,int> m;
    trav(t,v) m[t[0]] = m[t[1]] = 0;
    int co = 0;
    trav(t,m) t.s = ++co;
    trav(t,v) t[0] = m[t[0]], t[1] = m[t[1]];
    return v;
}

bool ans[1001];

int main() {
	m.init(2002);
    setIO(); re(n,k);
    vector<array<int,3>> v(n);
    re(v); trav(t,v) t[1] += t[0];
    auto V = compress(v);
    m.ae(0,1,k,0,-1);
    FOR(i,2,2002) m.ae(i-1,i,INF,0,-1);
    int co = 0;
    trav(t,V) m.ae(t[0],t[1],1,-t[2],++co);
    dbg("STARTING");
    m.calc(0,2001);
    dbg("ENDING");
    F0R(i,2002) trav(t,m.adj[i]) if (t.flo > 0) if (t.id > 0) ans[t.id] = 1;
    FOR(i,1,n+1) {
    	if (ans[i]) pr(1);
    	else pr(0);
    	pr(' ');
    }
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?), set tle
	* do smth instead of nothing and stay organized
*/


#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef string str;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;

typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); i--)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a : x)

#define mp make_pair
#define pb push_back
#define eb emplace_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert

const int MOD = 1e9+7; // 998244353 = (119<<23)+1
const ll INF = 1e18;
const int MX = 2e5+5;
const ld PI = 4*atan((ld)1);

template<class T> bool ckmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace __gnu_pbds;
using namespace __gnu_cxx;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ook order_of_key
#define fbo find_by_order

namespace input {
    template<class T> void re(complex<T>& x);
    template<class T1, class T2> void re(pair<T1,T2>& p);
    template<class T> void re(vector<T>& a);
    template<class T, size_t SZ> void re(array<T,SZ>& a);

    template<class T> void re(T& x) { cin >> x; }
    void re(double& x) { string t; re(t); x = stod(t); }
    void re(ld& x) { string t; re(t); x = stold(t); }
    template<class T, class... Ts> void re(T& t, Ts&... ts) {
        re(t); re(ts...);
    }

    template<class T> void re(complex<T>& x) { T a,b; re(a,b); x = cd(a,b); }
    template<class T1, class T2> void re(pair<T1,T2>& p) { re(p.f,p.s); }
    template<class T> void re(vector<T>& a) { F0R(i,sz(a)) re(a[i]); }
    template<class T, size_t SZ> void re(array<T,SZ>& a) { F0R(i,SZ) re(a[i]); }
}

using namespace input;

namespace output {
    void pr(int x) { cout << x; }
    void pr(long x) { cout << x; }
    void pr(ll x) { cout << x; }
    void pr(unsigned x) { cout << x; }
    void pr(unsigned long x) { cout << x; }
    void pr(unsigned long long x) { cout << x; }
    void pr(float x) { cout << x; }
    void pr(double x) { cout << x; }
    void pr(ld x) { cout << x; }
    void pr(char x) { cout << x; }
    void pr(const char* x) { cout << x; }
    void pr(const string& x) { cout << x; }
    void pr(bool x) { pr(x ? "true" : "false"); }
    template<class T> void pr(const complex<T>& x) { cout << x; }

    template<class T1, class T2> void pr(const pair<T1,T2>& x);
    template<class T> void pr(const T& x);

    template<class T, class... Ts> void pr(const T& t, const Ts&... ts) {
        pr(t); pr(ts...);
    }
    template<class T1, class T2> void pr(const pair<T1,T2>& x) {
        pr("{",x.f,", ",x.s,"}");
    }
    template<class T> void pr(const T& x) {
        pr("{"); // const iterator needed for vector<bool>
        bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0;
        pr("}");
    }

    void ps() { pr("\n"); } // print w/ spaces
    template<class T, class... Ts> void ps(const T& t, const Ts&... ts) {
        pr(t); if (sizeof...(ts)) pr(" "); ps(ts...);
    }

    void pc() { pr("]\n"); } // debug w/ commas
    template<class T, class... Ts> void pc(const T& t, const Ts&... ts) {
        pr(t); if (sizeof...(ts)) pr(", "); pc(ts...);
    }
    #define dbg(x...) pr("[",#x,"] = ["), pc(x);
}

using namespace output;

namespace io {
    void setIn(string s) { freopen(s.c_str(),"r",stdin); }
    void setOut(string s) { freopen(s.c_str(),"w",stdout); }
    void setIO(string s = "") {
        cin.sync_with_stdio(0); cin.tie(0); // fast I/O
        cin.exceptions(cin.failbit); // ex. throws exception when you try to read letter into int
        if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
    }
}

using namespace io;

template<class T> T invGeneral(T a, T b) {
	a %= b; if (a == 0) return b == 1 ? 0 : -1;
	T x = invGeneral(b,a);
	return x == -1 ? -1 : ((1-(ll)b*x)/a+b)%b;
}

template<class T> struct modular {
	T val;
	explicit operator T() const { return val; }
	modular() { val = 0; }
	modular(const ll& v) {
		val = (-MOD <= v && v <= MOD) ? v : v % MOD;
		if (val < 0) val += MOD;
	}

	// friend ostream& operator<<(ostream& os, const modular& a) { return os << a.val; }
	friend void pr(const modular& a) { pr(a.val); }
	friend void re(modular& a) { ll x; re(x); a = modular(x); }

	friend bool operator==(const modular& a, const modular& b) { return a.val == b.val; }
	friend bool operator!=(const modular& a, const modular& b) { return !(a == b); }
	friend bool operator<(const modular& a, const modular& b) { return a.val < b.val; }

	modular operator-() const { return modular(-val); }
	modular& operator+=(const modular& m) { if ((val += m.val) >= MOD) val -= MOD; return *this; }
	modular& operator-=(const modular& m) { if ((val -= m.val) < 0) val += MOD; return *this; }
	modular& operator*=(const modular& m) { val = (ll)val*m.val%MOD; return *this; }
	friend modular pow(modular a, ll p) {
		modular ans = 1; for (; p; p /= 2, a *= a) if (p&1) ans *= a;
		return ans;
	}
	friend modular inv(const modular& a) {
		auto i = invGeneral(a.val,MOD); assert(i != -1);
		return i;
	} // equivalent to return exp(b,MOD-2) if MOD is prime
	modular& operator/=(const modular& m) { return (*this) *= inv(m); }

	friend modular operator+(modular a, const modular& b) { return a += b; }
	friend modular operator-(modular a, const modular& b) { return a -= b; }
	friend modular operator*(modular a, const modular& b) { return a *= b; }

	friend modular operator/(modular a, const modular& b) { return a /= b; }
};

typedef modular<int> mi;
typedef pair<mi,mi> pmi;
typedef vector<mi> vmi;
typedef vector<pmi> vpmi;

/**
 * Description: Minimum-cost maximum flow, assumes no negative cycles.
 	* Edges may be negative only during first run of SPFA.
 * Time: $O(FM\log M)$ if caps are integers and $F$ is max flow
 * Source: GeeksForGeeks
 	* https://courses.csail.mit.edu/6.854/06/scribe/s12-minCostFlowAlg.pdf
 	* running time is only pseudo-polynomial; see https://codeforces.com/blog/entry/70740
 * Verification: https://codeforces.com/contest/164/problem/C
 */

template<int SZ> struct MCMF {
	typedef ll F; typedef ll C;
	struct Edge { int to, rev; F flow, cap; C cost; int id; };
	vector<Edge> adj[SZ];
	int N = 0, s, t; // # verts, source, sink
	void ae(int u, int v, F cap, C cost, int id = -1) {
		ckmax(N,max(u,v)+1); assert(cap >= 0);
		Edge a{v,sz(adj[v]),0,cap,cost,id}, b{u,sz(adj[u]),0,0,-cost,-1};
		adj[u].pb(a), adj[v].pb(b);
	}
	pi pre[SZ]; // previous vertex, edge label on path
	pair<C,F> cost[SZ]; // tot cost of path, amount of flow
	C totCost, curCost; F totFlow;
	bool spfa() { // find lowest cost path to send flow through
		F0R(i,N) cost[i] = {numeric_limits<C>::max(),0};
		cost[s] = {0,numeric_limits<F>::max()};
		typedef pair<C,int> T;
		priority_queue<T,vector<T>,greater<T>> todo;
		todo.push({0,s});
		while (sz(todo)) {
			T x = todo.top(); todo.pop();
			if (x.f > cost[x.s].f) continue;
			trav(a,adj[x.s]) if (a.flow < a.cap
				&& ckmin(cost[a.to].f,x.f+a.cost)) {
				pre[a.to] = {x.s,a.rev};
				cost[a.to].s = min(a.cap-a.flow,cost[x.s].s);
				todo.push({cost[a.to].f,a.to});
			} // if costs are doubles, add some EPS so you
		} // don't traverse ~0-weight cycle repeatedly
		return cost[t].s; // return flow
	}
	void backtrack() {
		F df = cost[t].s; totFlow += df;
		curCost += cost[t].f; totCost += curCost*df;
		for (int x = t; x != s; x = pre[x].f) {
			adj[x][pre[x].s].flow -= df;
			adj[pre[x].f][adj[x][pre[x].s].rev].flow += df;
		}
		F0R(i,N) trav(p,adj[i]) p.cost += cost[i].f-cost[p.to].f;
	} // all reduced costs non-negative if flow > 0
	// edges on shortest path become 0
	pair<F,C> calc(int _s, int _t) {
		s = _s, t = _t; totFlow = totCost = curCost = 0;
		while (spfa()) backtrack();
		return {totFlow,totCost};
	}
};

int n,k;
MCMF<2002> m;

vector<array<int,3>> compress(vector<array<int,3>> v) {
    map<int,int> m;
    trav(t,v) m[t[0]] = m[t[1]] = 0;
    int co = 0;
    trav(t,m) t.s = ++co;
    trav(t,v) t[0] = m[t[0]], t[1] = m[t[1]];
    return v;
}

bool ans[1001];

int main() {
    setIO(); re(n,k);
    vector<array<int,3>> v(n);
    re(v); trav(t,v) t[1] += t[0];
    auto V = compress(v);
    m.ae(0,1,k,0,-1);
    FOR(i,2,2002) m.ae(i-1,i,INF,0,-1);
    int co = 0;
    trav(t,V) m.ae(t[0],t[1],1,-t[2],++co);
    m.calc(0,2001);
    F0R(i,2002) trav(t,m.adj[i]) if (t.flow > 0) if (t.id > 0) ans[t.id] = 1;
    FOR(i,1,n+1) {
    	if (ans[i]) pr(1);
    	else pr(0);
    	pr(' ');
    }
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?), set tle
	* do smth instead of nothing and stay organized
*/


// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define debug(x) std::cerr << (#x) << ":\t" << (x) << std::endl;
#define NAME "Problem Name"

typedef long long ll;
typedef long double ld;

const double PI = atan2(0., -1.);
const int INF = 0x3f3f3f3f;
const int N = 1100 * 2;

class Edge {
 public:
	int from, to, cap, flow, cost;

	Edge() = default;

	Edge(int from, int to, int cap, int cost) : from(from), to(to), cap(cap), flow(0), cost(cost) {}
};

int s, t;
std::vector<Edge> edges;
std::vector<int> g[N];
int cnt[26];
int d[N], phi[N], p[N];
bool used[N];

void addEdge(int from, int to, int cap, int cost) {
	edges.emplace_back(from, to, cap, cost);
	g[from].push_back((int)edges.size() - 1);
	edges.emplace_back(to, from, 0, -cost);
	g[to].push_back((int)edges.size() - 1);
}

void spfa() {
	memset(d, INF, sizeof(d));
	memset(used, false, sizeof(used));

	std::queue<int> q;
	q.push(s);
	d[s] = 0;

	while (!q.empty()) {
		int v = q.front();
		q.pop();
		used[v] = false;

		for (auto i : g[v]) {
			int to = edges[i].to, cap = edges[i].cap, flow = edges[i].flow, cost = edges[i].cost;

			if (d[to] > d[v] + cost && cap > flow) {
				d[to] = d[v] + cost;
				p[to] = i;

				if (!used[to]) {
					used[to] = true;
					q.push(to);
				}
			}
		}
	}
}

std::pair<ll, int> minCostMaxFlow(int k) {
	ll ans = 0;
	int flow = 0;

	// debug(d[t]);

	for (int it = 0; it < k; ++it) {
		spfa();

		if (d[t] == INF) {
			return std::make_pair(ans, flow);
		}

		int push = INF;
		int i = t;
		while (i != s) {
			int cap = edges[p[i]].cap;
			int flow = edges[p[i]].flow;

			push = std::min(push, cap - flow);
			i = edges[p[i]].from;
		}

		// debug(push);

		flow += push;
		i = t;
		while (i != s) {
			edges[p[i]].flow += push;
			edges[p[i] ^ 1].flow -= push;
			ans += 1ll * push * edges[p[i]].cost;
			i = edges[p[i]].from;
		}
	}

	return std::make_pair(flow, ans);
}

int ss[N], tt[N], cc[N];

int main(void) {
	// #ifdef ONLINE_JUDGE
	// 	freopen(NAME".in", "r", stdin);
	// 	freopen(NAME".out", "w", stdout);
	// #endif

	int n, k;
	scanf("%d%d", &n, &k);

	for (int i = 0; i < n; ++i) {
		scanf("%d%d%d", &ss[i], &tt[i], &cc[i]);
	}

	s = 2 * n;
	t = 2 * n + 1;

	for (int i = 0; i < n; ++i) {
		addEdge(s, i, 1, 0);
		addEdge(i, i + n, 1, -cc[i]);
		addEdge(i + n, t, 1, 0);

		for (int j = 0; j < n; ++j) {
			if (ss[j] >= ss[i] + tt[i]) {
				addEdge(i + n, j, 1, 0);
			}
		}
	}

	minCostMaxFlow(k);

	for (int i = 0; i < n; ++i) {
		int cur = 0;

		for (auto j : g[i]) {
			int to = edges[j].to;
			int flow = edges[j].flow;

			if (to == n + i && flow == 1) {
				cur = 1;
				break;
			}
		}

		printf("%d ", cur);
	}

	printf("\n");

	return 0;
}


// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define debug(x) std::cerr << (#x) << ":\t" << (x) << std::endl;
#define NAME "Problem Name"

typedef long long ll;
typedef long double ld;

const double PI = atan2(0., -1.);
const int INF = 0x3f3f3f3f;
const int N = 1100 * 2;

class Edge {
 public:
	int from, to, cap, flow, cost;

	Edge() = default;

	Edge(int from, int to, int cap, int cost) : from(from), to(to), cap(cap), flow(0), cost(cost) {}
};

int s, t;
std::vector<Edge> edges;
std::vector<int> g[N];
int cnt[26];
int d[N], phi[N], p[N];
bool used[N];

void addEdge(int from, int to, int cap, int cost) {
	edges.emplace_back(from, to, cap, cost);
	g[from].push_back((int)edges.size() - 1);
	edges.emplace_back(to, from, 0, -cost);
	g[to].push_back((int)edges.size() - 1);
}

void spfa() {
	memset(d, INF, sizeof(d));
	memset(used, false, sizeof(used));

	std::queue<int> q;
	q.push(s);
	d[s] = 0;

	while (!q.empty()) {
		int v = q.front();
		q.pop();
		used[v] = false;

		for (auto i : g[v]) {
			int to = edges[i].to, cap = edges[i].cap, flow = edges[i].flow, cost = edges[i].cost;

			if (d[to] > d[v] + cost && cap > flow) {
				d[to] = d[v] + cost;
				p[to] = i;

				if (!used[to]) {
					used[to] = true;
					q.push(to);
				}
			}
		}
	}
}

std::pair<ll, int> minCostMaxFlow(int k) {
	ll ans = 0;
	int flow = 0;

	// debug(d[t]);

	for (int it = 0; it < k; ++it) {
		spfa();

		if (d[t] == INF) {
			return std::make_pair(ans, flow);
		}

		int push = INF;
		int i = t;
		while (i != s) {
			int cap = edges[p[i]].cap;
			int flow = edges[p[i]].flow;

			push = std::min(push, cap - flow);
			i = edges[p[i]].from;
		}

		// debug(push);

		flow += push;
		i = t;
		while (i != s) {
			edges[p[i]].flow += push;
			edges[p[i] ^ 1].flow -= push;
			ans += 1ll * push * edges[p[i]].cost;
			i = edges[p[i]].from;
		}
	}

	return std::make_pair(flow, ans);
}

int ss[N], tt[N], cc[N];

int main(void) {
	// #ifdef ONLINE_JUDGE
	// 	freopen(NAME".in", "r", stdin);
	// 	freopen(NAME".out", "w", stdout);
	// #endif

	int n, k;
	scanf("%d%d", &n, &k);

	for (int i = 0; i < n; ++i) {
		scanf("%d%d%d", &ss[i], &tt[i], &cc[i]);
	}

	s = 2 * n;
	t = 2 * n + 1;

	for (int i = 0; i < n; ++i) {
		addEdge(s, i, 1, 0);
		addEdge(i, i + n, 1, -cc[i]);
		addEdge(i + n, t, 1, 0);

		for (int j = 0; j < n; ++j) {
			if (ss[j] >= ss[i] + tt[i]) {
				addEdge(i + n, j, 1, 0);
			}
		}
	}

	minCostMaxFlow(k);

	for (int i = 0; i < n; ++i) {
		int cur = 0;

		for (auto j : g[i]) {
			int to = edges[j].to;
			int flow = edges[j].flow;

			if (to == n + i && flow == 1) {
				cur = 1;
				break;
			}
		}

		printf("%d ", cur);
	}

	printf("\n");

	return 0;
}


// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define debug(x) std::cerr << (#x) << ":\t" << (x) << std::endl;
#define NAME "Problem Name"

typedef long long ll;
typedef long double ld;

const double PI = atan2(0., -1.);
const int INF = 0x3f3f3f3f;
const int N = 1100 * 2;

class Edge {
 public:
	int from, to, cap, flow, cost;

	Edge() = default;

	Edge(int from, int to, int cap, int cost) : from(from), to(to), cap(cap), flow(0), cost(cost) {}
};

int s, t;
std::vector<Edge> edges;
std::vector<int> g[N];
int cnt[26];
int d[N], phi[N], p[N];
bool used[N];

void addEdge(int from, int to, int cap, int cost) {
	edges.emplace_back(from, to, cap, cost);
	g[from].push_back((int)edges.size() - 1);
	edges.emplace_back(to, from, 0, -cost);
	g[to].push_back((int)edges.size() - 1);
}

void spfa() {
	memset(d, INF, sizeof(d));
	memset(used, false, sizeof(used));

	std::queue<int> q;
	q.push(s);
	d[s] = 0;

	while (!q.empty()) {
		int v = q.front();
		q.pop();
		used[v] = false;

		for (auto i : g[v]) {
			int to = edges[i].to, cap = edges[i].cap, flow = edges[i].flow, cost = edges[i].cost;

			if (d[to] > d[v] + cost && cap > flow) {
				d[to] = d[v] + cost;
				p[to] = i;

				if (!used[to]) {
					used[to] = true;
					q.push(to);
				}
			}
		}
	}
}

std::pair<ll, int> minCostMaxFlow(int k) {
	ll ans = 0;
	int flow = 0;

	// debug(d[t]);

	for (int it = 0; it < k; ++it) {
		spfa();

		if (d[t] == INF) {
			return std::make_pair(ans, flow);
		}

		int push = INF;
		int i = t;
		while (i != s) {
			int cap = edges[p[i]].cap;
			int flow = edges[p[i]].flow;

			push = std::min(push, cap - flow);
			i = edges[p[i]].from;
		}

		// debug(push);

		flow += push;
		i = t;
		while (i != s) {
			edges[p[i]].flow += push;
			edges[p[i] ^ 1].flow -= push;
			ans += 1ll * push * edges[p[i]].cost;
			i = edges[p[i]].from;
		}
	}

	return std::make_pair(flow, ans);
}

int ss[N], tt[N], cc[N];
int id[N];

int main(void) {
	// #ifdef ONLINE_JUDGE
	// 	freopen(NAME".in", "r", stdin);
	// 	freopen(NAME".out", "w", stdout);
	// #endif

	int n, k;
	scanf("%d%d", &n, &k);

	std::vector<int> trans;

	for (int i = 0; i < n; ++i) {
		scanf("%d%d%d", &ss[i], &tt[i], &cc[i]);

		trans.push_back(ss[i]);
		trans.push_back(ss[i] + tt[i]);
	}

	std::sort(trans.begin(), trans.end());
	trans.resize(std::unique(trans.begin(), trans.end()) - trans.begin());

	for (int i = 0; i < (int)trans.size() - 1; ++i) {
		addEdge(i, i + 1, k, 0);
	}

	for (int i = 0; i < n; ++i) {
		int from = std::lower_bound(trans.begin(), trans.end(), ss[i]) - trans.begin();
		int to = std::lower_bound(trans.begin(), trans.end(), ss[i] + tt[i]) - trans.begin();
		id[i] = (int)edges.size();
		addEdge(from, to, 1, -cc[i]);
	}

	s = 0;
	t = (int)trans.size() - 1;

	minCostMaxFlow(k);

	for (int i = 0; i < n; ++i) {
		printf("%d ", edges[id[i]].flow);
	}

	printf("\n");

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
int mul(int a, int b) {return 1ll * a * b % P;}
int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//---
const int inf = 1e9 + 7;

template <class U, class V>
struct ZKW{
	static const int N = 2010, M = 40040;
	int h[N], ing[N], v[N], to[M], ne[M], e, s, t, n;
	U cap[M]; V dis[N], cost[M];
	void ini(int _n = N) {fill(h, h + (n = _n), -1); e = 0;}
	void liu(int u, int v, U c, V w) {to[e] = v; ne[e] = h[u];cap[e] = c; cost[e] = w; h[u] = e++;}
	void link(int u, int v, U c, V w) {liu(u, v, c, w);liu(v, u, 0, -w);}
	void spfa() {
		queue<int> Q;
		fill(dis, dis+n, inf);
		ing[t] = 1, dis[t] =0;
		Q.push(t);
		while (!Q.empty()) {
			int c = Q.front();Q.pop();ing[c] = 0;
			for(int k = h[c]; ~k; k = ne[k]) {
				int v = to[k];
				if(cap[k^1] <= 0) continue;
				if (dis[c] + cost[k ^ 1] < dis[v]) {
					dis[v] = dis[c] + cost[k ^ 1];
					if (!ing[v]) Q.push(v), ing[v] = 1;
				}
			}
		}
	}
	U flow; V mincost;
	bool modlable() {
		V Min = inf;
		rep(c, 0, n) if (v[c])
			for (int k = h[c]; ~k; k = ne[k]) {
				int t = to[k];
				if (!v[t] && cap[k] > 0)
						Min = min(Min, dis[t] + cost[k] - dis[c]);
			}
		if (Min == inf) return 0;
		rep(i, 0, n) if (v[i]) dis[i] += Min;
		//if (dis[s] >= 0) return 0;
		return 1;
	}
	U dfs(int c, U mx) {
		if (c == t) return flow += mx, mincost += mx * dis[s], mx;
		v[c] = 1; U ret = 0;
		for (int k = h[c]; ~k; k = ne[k]) {
			int t = to[k];
			if (!v[t] && cap[k] > 0 && dis[c] - cost[k] == dis[t]) {
				U tmp = dfs(t, min(cap[k], mx - ret));
				cap[k] -= tmp, cap[k ^ 1] += tmp;
				ret += tmp;
				if (ret == mx) return ret;
			}
		}
		return ret;
	}
	pair<U, V> run(int _s, int _t) {
		s = _s, t = _t;
		spfa();
		flow = mincost = 0;
		do do memset(v, 0, sizeof(v[0]) * n);
			while (dfs(s, inf));
		while(modlable());
		return mp(flow, mincost);
	}
};

ZKW<int, int> G;
const int N = 100005;
int l[N], r[N], da[N];
vi V;
int T, n, m, k;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	//cout << setiosflags(ios::fixed);
	//cout << setprecision(2);
	T = 1;
	while(T--) {
		cin >> m >> k;
		V.clear();
		rep(i, 0, m) cin >> l[i] >> r[i] >> da[i], V.pb(l[i]), r[i] += l[i] - 1;
		V.pb(0), V.pb(inf * 2);
		sort(all(V));V.erase(unique(all(V)), V.end());
		n = sz(V);
		G.ini(n);
		rep(i, 1, n) G.link(i - 1, i, k, 0);
		int st = G.e;
		rep(i, 0, m) {
			l[i] = lower_bound(all(V), l[i]) - V.begin();
			r[i] = upper_bound(all(V), r[i]) - V.begin();
			G.link(l[i], r[i], 1, -da[i]);
		}
		//cout << -G.run(0,n-1).se << endl;
		G.run(0, n - 1);
		rep(i, 0, m) {
			if (G.cap[i * 2 + st] == 0) cout << 1;else cout << 0;
			cout << " ";
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
int mul(int a, int b) {return 1ll * a * b % P;}
int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//---
const int inf = 1e9 + 7;

template <class U, class V>
struct ZKW{
	static const int N = 2010, M = 40040;
	int h[N], ing[N], v[N], to[M], ne[M], e, s, t, n;
	U cap[M]; V dis[N], cost[M];
	void ini(int _n = N) {fill(h, h + (n = _n), -1); e = 0;}
	void liu(int u, int v, U c, V w) {to[e] = v; ne[e] = h[u];cap[e] = c; cost[e] = w; h[u] = e++;}
	void link(int u, int v, U c, V w) {liu(u, v, c, w);liu(v, u, 0, -w);}
	void spfa() {
		queue<int> Q;
		fill(dis, dis+n, inf);
		ing[t] = 1, dis[t] =0;
		Q.push(t);
		while (!Q.empty()) {
			int c = Q.front();Q.pop();ing[c] = 0;
			for(int k = h[c]; ~k; k = ne[k]) {
				int v = to[k];
				if(cap[k^1] <= 0) continue;
				if (dis[c] + cost[k ^ 1] < dis[v]) {
					dis[v] = dis[c] + cost[k ^ 1];
					if (!ing[v]) Q.push(v), ing[v] = 1;
				}
			}
		}
	}
	U flow; V mincost;
	bool modlable() {
		V Min = inf;
		rep(c, 0, n) if (v[c])
			for (int k = h[c]; ~k; k = ne[k]) {
				int t = to[k];
				if (!v[t] && cap[k] > 0)
						Min = min(Min, dis[t] + cost[k] - dis[c]);
			}
		if (Min == inf) return 0;
		rep(i, 0, n) if (v[i]) dis[i] += Min;
		if (dis[s] >= 0) return 0;
		return 1;
	}
	U dfs(int c, U mx) {
		if (c == t) return flow += mx, mincost += mx * dis[s], mx;
		v[c] = 1; U ret = 0;
		for (int k = h[c]; ~k; k = ne[k]) {
			int t = to[k];
			if (!v[t] && cap[k] > 0 && dis[c] - cost[k] == dis[t]) {
				U tmp = dfs(t, min(cap[k], mx - ret));
				cap[k] -= tmp, cap[k ^ 1] += tmp;
				ret += tmp;
				if (ret == mx) return ret;
			}
		}
		return ret;
	}
	pair<U, V> run(int _s, int _t) {
		s = _s, t = _t;
		spfa();
		flow = mincost = 0;
		do do memset(v, 0, sizeof(v[0]) * n);
			while (dfs(s, inf));
		while(modlable());
		return mp(flow, mincost);
	}
};

ZKW<int, int> G;
const int N = 100005;
int l[N], r[N], da[N];
vi V;
int T, n, m, k;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	//cout << setiosflags(ios::fixed);
	//cout << setprecision(2);
	T = 1;
	while(T--) {
		cin >> m >> k;
		V.clear();
		rep(i, 0, m) cin >> l[i] >> r[i] >> da[i], V.pb(l[i]), r[i] += l[i] - 1;
		V.pb(0), V.pb(inf * 2);
		sort(all(V));V.erase(unique(all(V)), V.end());
		n = sz(V);
		G.ini(n);
		rep(i, 1, n) G.link(i - 1, i, k, 0);
		int st = G.e;
		rep(i, 0, m) {
			l[i] = lower_bound(all(V), l[i]) - V.begin();
			r[i] = upper_bound(all(V), r[i]) - V.begin();
			G.link(l[i], r[i], 1, -da[i]);
		}
		//cout << -G.run(0,n-1).se << endl;
		G.run(0, n - 1);
		rep(i, 0, m) {
			if (G.cap[i * 2 + st] == 0) cout << 1;else cout << 0;
			cout << " ";
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
int mul(int a, int b) {return 1ll * a * b % P;}
int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//---
const int inf = 1e9 + 7;

template <class U, class V>
struct ZKW{
	static const int N = 2010, M = 40040;
	int h[N], ing[N], v[N], to[M], ne[M], e, s, t, n;
	U cap[M]; V dis[N], cost[M];
	void ini(int _n = N) {fill(h, h + (n = _n), -1); e = 0;}
	void liu(int u, int v, U c, V w) {to[e] = v; ne[e] = h[u];cap[e] = c; cost[e] = w; h[u] = e++;}
	void link(int u, int v, U c, V w) {liu(u, v, c, w);liu(v, u, 0, -w);}
	void spfa() {
		queue<int> Q;
		fill(dis, dis+n, inf);
		ing[t] = 1, dis[t] =0;
		Q.push(t);
		while (!Q.empty()) {
			int c = Q.front();Q.pop();ing[c] = 0;
			for(int k = h[c]; ~k; k = ne[k]) {
				int v = to[k];
				if(cap[k^1] <= 0) continue;
				if (dis[c] + cost[k ^ 1] < dis[v]) {
					dis[v] = dis[c] + cost[k ^ 1];
					if (!ing[v]) Q.push(v), ing[v] = 1;
				}
			}
		}
	}
	U flow; V mincost;
	bool modlable() {
		V Min = inf;
		rep(c, 0, n) if (v[c])
			for (int k = h[c]; ~k; k = ne[k]) {
				int t = to[k];
				if (!v[t] && cap[k] > 0)
						Min = min(Min, dis[t] + cost[k] - dis[c]);
			}
		//if (Min >= 0) return 0;
		if (Min == inf) return 0;
		rep(i, 0, n) if (v[i]) dis[i] += Min;
		return 1;
	}
	U dfs(int c, U mx) {
		if (c == t) return flow += mx, mincost += mx * dis[s], mx;
		v[c] = 1; U ret = 0;
		for (int k = h[c]; ~k; k = ne[k]) {
			int t = to[k];
			if (!v[t] && cap[k] > 0 && dis[c] - cost[k] == dis[t]) {
				U tmp = dfs(t, min(cap[k], mx - ret));
				cap[k] -= tmp, cap[k ^ 1] += tmp;
				ret += tmp;
				if (ret == mx) return ret;
			}
		}
		return ret;
	}
	pair<U, V> run(int _s, int _t) {
		s = _s, t = _t;
		spfa();
		flow = mincost = 0;
		do do memset(v, 0, sizeof(v[0]) * n);
			while (dfs(s, inf));
		while(modlable());
		return mp(flow, mincost);
	}
};

ZKW<int, int> G;
const int N = 100005;
int l[N], r[N], da[N];
vi V;
int T, n, m, k;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	//cout << setiosflags(ios::fixed);
	//cout << setprecision(2);
	T = 1;
	while(T--) {
		cin >> m >> k;
		V.clear();
		rep(i, 0, m) cin >> l[i] >> r[i] >> da[i], V.pb(l[i]), r[i] += l[i] - 1;
		V.pb(0), V.pb(inf);
		sort(all(V));V.erase(unique(all(V)), V.end());
		n = sz(V);
		G.ini(n);
		rep(i, 1, n) G.link(i - 1, i, k, 0);
		int st = G.e;
		rep(i, 0, m) {
			l[i] = lower_bound(all(V), l[i]) - V.begin();
			r[i] = upper_bound(all(V), r[i]) - V.begin();
			G.link(l[i], r[i], 1, -da[i]);
		}
		//cout << -G.run(0,n-1).se << endl;
		G.run(0, n - 1);
		rep(i, 0, m) {
			if (G.cap[i * 2 + st] == 0) cout << 1;else cout << 0;
			cout << " ";
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
int mul(int a, int b) {return 1ll * a * b % P;}
int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//---
const int inf = 1e9 + 7;

template <class U, class V>
struct ZKW{
	static const int N = 2010, M = 40040;
	int h[N], ing[N], v[N], to[M], ne[M], e, s, t, n;
	U cap[M]; V dis[N], cost[M];
	void ini(int _n = N) {fill(h, h + (n = _n), -1); e = 0;}
	void liu(int u, int v, U c, V w) {to[e] = v; ne[e] = h[u];cap[e] = c; cost[e] = w; h[u] = e++;}
	void link(int u, int v, U c, V w) {liu(u, v, c, w);liu(v, u, 0, -w);}
	void spfa() {
		queue<int> Q;
		fill(dis, dis+n, inf);
		ing[t] = 1, dis[t] =0;
		Q.push(t);
		while (!Q.empty()) {
			int c = Q.front();Q.pop();ing[c] = 0;
			for(int k = h[c]; ~k; k = ne[k]) {
				int v = to[k];
				if(cap[k^1] <= 0) continue;
				if (dis[c] + cost[k ^ 1] < dis[v]) {
					dis[v] = dis[c] + cost[k ^ 1];
					if (!ing[v]) Q.push(v), ing[v] = 1;
				}
			}
		}
	}
	U flow; V mincost;
	bool modlable() {
		V Min = inf;
		rep(c, 0, n) if (v[c])
			for (int k = h[c]; ~k; k = ne[k]) {
				int t = to[k];
				if (!v[t] && cap[k] > 0)
						Min = min(Min, dis[t] + cost[k] - dis[c]);
			}
		if (Min == inf) return 0;
		rep(i, 0, n) if (v[i]) dis[i] += Min;
		if (dis[s] >= 0) return 0;
		return 1;
	}
	U dfs(int c, U mx) {
		if (c == t) return flow += mx, mincost += mx * dis[s], mx;
		v[c] = 1; U ret = 0;
		for (int k = h[c]; ~k; k = ne[k]) {
			int t = to[k];
			if (!v[t] && cap[k] > 0 && dis[c] - cost[k] == dis[t]) {
				U tmp = dfs(t, min(cap[k], mx - ret));
				cap[k] -= tmp, cap[k ^ 1] += tmp;
				ret += tmp;
				if (ret == mx) return ret;
			}
		}
		return ret;
	}
	pair<U, V> run(int _s, int _t) {
		s = _s, t = _t;
		spfa();
		flow = mincost = 0;
		do do memset(v, 0, sizeof(v[0]) * n);
			while (dfs(s, inf));
		while(modlable());
		return mp(flow, mincost);
	}
};

ZKW<int, int> G;
const int N = 100005;
int l[N], r[N], da[N];
vi V;
int T, n, m, k;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	//cout << setiosflags(ios::fixed);
	//cout << setprecision(2);
	T = 1;
	while(T--) {
		cin >> m >> k;
		V.clear();
		rep(i, 0, m) cin >> l[i] >> r[i] >> da[i], V.pb(l[i]), r[i] += l[i] - 1;
		V.pb(0), V.pb(inf);
		sort(all(V));V.erase(unique(all(V)), V.end());
		n = sz(V);
		G.ini(n);
		rep(i, 1, n) G.link(i - 1, i, k, 0);
		int st = G.e;
		rep(i, 0, m) {
			l[i] = lower_bound(all(V), l[i]) - V.begin();
			r[i] = upper_bound(all(V), r[i]) - V.begin();
			G.link(l[i], r[i], 1, -da[i]);
		}
		//cout << -G.run(0,n-1).se << endl;
		G.run(0, n - 1);
		rep(i, 0, m) {
			if (G.cap[i * 2 + st] == 0) cout << 1;else cout << 0;
			cout << " ";
		}
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define rep(i, a, b) for(int i=(a); i<(b); i++)
#define per(i, a, b) for(int i=(b)-1; i>=(a); i--)
#define sz(a) (int)a.size()
#define de(a) cout << #a << " = " << a << endl
#define dd(a) cout << #a << " = " << a << " "
#define all(a) a.begin(), a.end()
#define pw(x) (1ll<<(x))
#define endl "\n"
typedef int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int P = 1e9 + 7;
int add(int a, int b) {if((a += b) >= P) a -= P; return a;}
int sub(int a, int b) {if((a -= b) < 0) a += P; return a;}
int mul(int a, int b) {return 1ll * a * b % P;}
int kpow(int a, int b) {int r=1;for(;b;b>>=1,a=mul(a,a)) {if(b&1)r=mul(r,a);}return r;}
//---
const int N=100005;
int l[N],r[N],data[N];
vector<int> V;
//----

const int inf = 1e9 + 7;

template <class U, class V>
struct ZKW{
	static const int N = 2010, M = 40040;
	int h[N], ing[N], v[N], to[M], ne[M], e, s, t, n;
	U cap[M]; V dis[N], cost[M];
	void ini(int _n = N) {fill(h, h + (n = _n), -1); e = 0;}
	void liu(int u, int v, U c, V w) {to[e] = v; ne[e] = h[u];cap[e] = c; cost[e] = w; h[u] = e++;}
	void link(int u, int v, U c, V w) {liu(u, v, c, w);liu(v, u, 0, -w);}
	void spfa() {
		queue<int> Q;
		fill(dis, dis+n, inf);
		ing[t] = 1, dis[t] =0;
		Q.push(t);
		while (!Q.empty()) {
			int c = Q.front();Q.pop();ing[c] = 0;
			for(int k = h[c]; ~k; k = ne[k]) {
				int v = to[k];
				if(cap[k^1] <= 0) continue;
				if (dis[c] + cost[k ^ 1] < dis[v]) {
					dis[v] = dis[c] + cost[k ^ 1];
					if (!ing[v]) Q.push(v), ing[v] = 1;
				}
			}
		}
	}
	U flow; V mincost;
	bool modlable() {
		V Min = inf;
		rep(c, 0, n) if (v[c])
			for (int k = h[c]; ~k; k = ne[k]) {
				int t = to[k];
				if (!v[t] && cap[k] > 0)
						Min = min(Min, dis[t] + cost[k] - dis[c]);
			}
		//if (Min >= 0) return 0;
		if (Min == inf) return 0;
		rep(i, 0, n) if (v[i]) dis[i] += Min;
		return 1;
	}
	U dfs(int c, U mx) {
		if (c == t) return flow += mx, mincost += mx * dis[s], mx;
		v[c] = 1; U ret = 0;
		for (int k = h[c]; ~k; k = ne[k]) {
			int t = to[k];
			if (!v[t] && cap[k] > 0 && dis[c] - cost[k] == dis[t]) {
				U tmp = dfs(t, min(cap[k], mx - ret));
				cap[k] -= tmp, cap[k ^ 1] += tmp;
				ret += tmp;
				if (ret == mx) return ret;
			}
		}
		return ret;
	}
	pair<U, V> run(int _s, int _t) {
		s = _s, t = _t;
		spfa();
		flow = mincost = 0;
		do do memset(v, 0, sizeof(v[0]) * n);
			while (dfs(s, inf));
		while(modlable());
		return mp(flow, mincost);
	}
};

ZKW<int, int> G;
int T, n, m, k;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	//cout << setiosflags(ios::fixed);
	//cout << setprecision(2);
	T = 1;
	while(T--) {
		cin >> m >> k;
		V.clear();
		rep(i, 0, m) cin >> l[i] >> r[i] >> data[i], V.pb(l[i]), r[i] += l[i] - 1;
		V.pb(0), V.pb(inf);
		sort(all(V));V.erase(unique(all(V)), V.end());
		n = sz(V);
		G.ini(n);
		rep(i, 1, n) G.link(i - 1, i, k, 0);
		int st = G.e;
		rep(i, 0, m) {
			l[i] = lower_bound(all(V), l[i]) - V.begin();
			r[i] = upper_bound(all(V), r[i]) - V.begin();
			G.link(l[i], r[i], 1, -data[i]);
		}
		//cout << -G.run(0,n-1).se << endl;
		G.run(0, n - 1);
		rep(i, 0, m) {
			if (G.cap[i * 2 + st] == 0) cout << 1;else cout << 0;
			cout << " ";
		}
	}
	return 0;
}


/*input
3 1
2 7 5
1 3 3
4 1 3
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define bit(x,y) ((x>>y)&1)
#define loop(i,l,r) for(int i=(int)l; i<=(int)r; i++)
#define rloop(i,l,r) for(int i=(int)l; i>=(int)r; i--)
#ifdef UncleGrandpa
#include <prettyprint.hpp>
void print() {cout << endl;} template<typename T, typename... Ts> void print(const T& value, const Ts&... values) {cout << value << ' ', print(values...);}
void debug() {cerr << endl;} template<typename T, typename... Ts> void debug(const T& value, const Ts&... values) {cerr << value << ' ', debug(values...);}
#endif

const int INF = numeric_limits<int>::max() / 2;
struct MinCostMaxFlow {
    struct Edge {
        int u, v, cap, f, cost; // f represent remaining flow
        Edge (int _u, int _v, int _cap, int _f, int _cost): u(_u), v(_v), cap(_cap), f(_f), cost(_cost) {};
    };
    priority_queue<pair<int, int> , vector<pair<int, int> >, greater<pair<int, int> > > pq;
    vector<Edge> e;
    vector<vector<int> > a;
    vector<int> dis, par;
    int n, S, T;
    bool dijkstra() {
        while (!pq.empty()) pq.pop();
        fill(dis.begin(), dis.end(), INF); fill(par.begin(), par.end(), -1);
        dis[S] = 0; pq.push({0, S});
        while (!pq.empty()) {
            auto [cud, u] = pq.top(); pq.pop();
            if (cud != dis[u]) continue;
            for (auto id : a[u]) {
                auto &t = e[id]; auto v = e[id].v;
                if (t.f && dis[v] > dis[u] + t.cost) {
                    dis[v] = dis[u] + t.cost;
                    par[v] = id;
                    pq.push({dis[v], v});
                }
            }
        }
        if (dis[T] != INF) return true;
        return false;
    }
    int dfs() {
        int delta = INF, u = T;
        while (u != S) {
            delta = min(delta, e[par[u]].f);
            u = e[par[u]].u;
        }
        u = T;
        while (u != S) {
            e[par[u]].f -= delta;
            e[par[u] ^ 1].f += delta;
            u = e[par[u]].u;
        }
        return delta;
    }
    void init(int _n, int _S, int _T) {
        n = _n; S = _S; T = _T; e.clear();
        a.assign(n, vector<int>()); dis.assign(n, 0); par.assign(n, 0);
    }
    void addEdge(int u, int v, int cap, int cost) {
        e.push_back({u, v, cap, cap, cost});
        e.push_back({v, u, 0, 0, -cost});
        a[u].push_back(e.size() - 2);
        a[v].push_back(e.size() - 1);
    }
    pair<int, int> solve() {
        pair<int, int> ret = {0, 0};
        while (dijkstra()) ret.fi += dfs();
        for (auto &rx : e) if (rx.cap > rx.f) ret.se += (rx.cap - rx.f) * rx.cost;
        return ret;
    }
} MCMF;

struct Task {
    int l, r, c;
    Task(int _l, int _t, int _c) {
        l = _l;
        r = l + _t - 1;
        c = _c;
    }
};
ostream &operator<<(ostream &os, Task X) {
    os << X.l << sp << X.r << sp << X.c;
    return os;
}

#define IN 0
#define OUT 1

int n, m;
int S = 0, T = 1;
vector<Task> tasks;
vector<int> all;

int gMa(int p) { // 0-based
    return T + p + 1;
}

int gTa(int p, bool type) {
    return T + m + 1 + p * 2 + type;
}

int gPiv(int p) {
    return T + m + 2 * n + p + 1;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    loop(i, 1, n) {
        int l, r, c;
        cin >> l >> r >> c;
        tasks.push_back(Task(l, r, c));
        all.push_back(tasks.back().l); all.push_back(tasks.back().r);
    }

    all.push_back(INF);
    sort(all.begin(), all.end()); all.resize(distance(all.begin(), unique(all.begin(), all.end())));
    for (auto &it : tasks) {
        it.l = lower_bound(all.begin(), all.end(), it.l) - all.begin();
        it.r = lower_bound(all.begin(), all.end(), it.r) - all.begin();
        // print(it.l, it.r);
    }

    MCMF.init(gPiv(all.size() - 1) + 1, S, T);
    loop(i, 0, m - 1) {
        MCMF.addEdge(S, gMa(i), 1, 0);
        MCMF.addEdge(gMa(i), gPiv(0), 1, 0);
    }
    loop(i, 0, all.size() - 1) {
        if (i != all.size() - 1)
            MCMF.addEdge(gPiv(i), gPiv(i + 1), INF, 0);
        else
            MCMF.addEdge(gPiv(i), T, INF, 0);
    }

    loop(i, 0, n - 1) {
        MCMF.addEdge(gPiv(tasks[i].l), gTa(i, IN), INF, 0);
        MCMF.addEdge(gTa(i, IN), gTa(i, OUT), 1, -tasks[i].c);
        MCMF.addEdge(gTa(i, OUT), gPiv(tasks[i].r + 1), INF, 0);
    }

    MCMF.solve();
    vector<bool> ans(n, 0);
    map<pair<int, int>, int> mark;
    for (auto it : MCMF.e) {
        mark[ {it.u, it.v}] = it.cap - it.f;
    }
    loop(i, 0, n - 1) {
        if (mark[ {gTa(i, IN), gTa(i, OUT)}] != 0) cout << 1 << sp;
        else cout << 0 << sp;
    }
    cout << endl;
}


/*input
3 1
2 7 5
1 3 3
4 1 3
*/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define bit(x,y) ((x>>y)&1)
#define loop(i,l,r) for(int i=(int)l; i<=(int)r; i++)
#define rloop(i,l,r) for(int i=(int)l; i>=(int)r; i--)
#ifdef UncleGrandpa
#include <prettyprint.hpp>
void print() {cout << endl;} template<typename T, typename... Ts> void print(const T& value, const Ts&... values) {cout << value << ' ', print(values...);}
void debug() {cerr << endl;} template<typename T, typename... Ts> void debug(const T& value, const Ts&... values) {cerr << value << ' ', debug(values...);}
#endif

const int INF = numeric_limits<int>::max() / 2;
struct MinCostMaxFlow {
    struct Edge {
        int u, v, cap, f, cost; // f represent remaining flow
        Edge (int _u, int _v, int _cap, int _f, int _cost): u(_u), v(_v), cap(_cap), f(_f), cost(_cost) {};
    };
    priority_queue<pair<int, int> , vector<pair<int, int> >, greater<pair<int, int> > > pq;
    vector<Edge> e;
    vector<vector<int> > a;
    vector<int> dis, par;
    int n, S, T;
    bool dijkstra() {
        while (!pq.empty()) pq.pop();
        fill(dis.begin(), dis.end(), INF); fill(par.begin(), par.end(), -1);
        dis[S] = 0; pq.push({0, S});
        while (!pq.empty()) {
            auto [cud, u] = pq.top(); pq.pop();
            if (cud != dis[u]) continue;
            for (auto id : a[u]) {
                auto &t = e[id]; auto v = e[id].v;
                if (t.f && dis[v] > dis[u] + t.cost) {
                    dis[v] = dis[u] + t.cost;
                    par[v] = id;
                    pq.push({dis[v], v});
                }
            }
        }
        if (dis[T] != INF) return true;
        return false;
    }
    int dfs() {
        int delta = INF, u = T;
        while (u != S) {
            delta = min(delta, e[par[u]].f);
            u = e[par[u]].u;
        }
        u = T;
        while (u != S) {
            e[par[u]].f -= delta;
            e[par[u] ^ 1].f += delta;
            u = e[par[u]].u;
        }
        return delta;
    }
    void init(int _n, int _S, int _T) {
        n = _n; S = _S; T = _T; e.clear();
        a.assign(n, vector<int>()); dis.assign(n, 0); par.assign(n, 0);
    }
    void addEdge(int u, int v, int cap, int cost) {
        e.push_back({u, v, cap, cap, cost});
        e.push_back({v, u, 0, 0, -cost});
        a[u].push_back(e.size() - 2);
        a[v].push_back(e.size() - 1);
    }
    pair<int, int> solve() {
        pair<int, int> ret = {0, 0};
        while (dijkstra()) ret.fi += dfs();
        for (auto &rx : e) if (rx.cap > rx.f) ret.se += (rx.cap - rx.f) * rx.cost;
        return ret;
    }
} MCMF;

struct Task {
    int l, r, c;
    Task(int _l, int _t, int _c) {
        l = _l;
        r = l + _t - 1;
        c = _c;
    }
};
ostream &operator<<(ostream &os, Task X) {
    os << X.l << sp << X.r << sp << X.c;
    return os;
}

int n, m;
int S = 0, T = 1;

vector<Task> tasks;

int gMa(int p) { // 0-based
    return T + p + 1;
}

#define IN 0
#define OUT 1
int gTa(int p, bool type) {
    return T + m + 1 + p * 2 + type;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    loop(i, 1, n) {
        int l, r, c;
        cin >> l >> r >> c;
        tasks.push_back(Task(l, r, c));
    }
    // print(tasks);
    MCMF.init(gTa(n, OUT) + 1, S, T);
    loop(i, 0, m - 1) {
        MCMF.addEdge(S, gMa(i), 1, 0);
    }
    loop(i, 0, n - 1) {
        MCMF.addEdge(gTa(i, IN), gTa(i, OUT), 1, -tasks[i].c);
        MCMF.addEdge(gTa(i, OUT), T, 1, 0);
    }
    loop(i, 0, m - 1) {
        loop(j, 0, n - 1) {
            MCMF.addEdge(gMa(i), gTa(j, IN), 1, 0);
        }
    }
    loop(i, 0, n - 1) {
        loop(j, 0, n - 1) {
            if (i == j) continue;
            if (tasks[i].r < tasks[j].l) {
                // print(i, j);
                MCMF.addEdge(gTa(i, OUT), gTa(j, IN), INF, 0);
            }
        }
    }

    MCMF.solve();
    vector<bool> ans(n, 0);
    map<pair<int, int>, int> mark;
    for (auto it : MCMF.e) {
        mark[ {it.u, it.v}] = it.cap - it.f;
    }
    loop(i, 0, n - 1) {
        if (mark[ {gTa(i, IN), gTa(i, OUT)}] != 0) cout << 1 << sp;
        else cout << 0 << sp;
    }
    cout << endl;
}


/*input
10 2
699300217 520863246 750739
158802156 776305466 388177
556239371 900142068 187357
776489007 632844082 238502
361186251 188888255 483934
154509737 958411614 416129
777488390 894434905 348016
558588067 756129429 77163
938486404 462702730 640265
593570035 525346237 888643
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define bit(x,y) ((x>>y)&1)
#define loop(i,l,r) for(int i=(int)l; i<=(int)r; i++)
#define rloop(i,l,r) for(int i=(int)l; i>=(int)r; i--)
#ifdef UncleGrandpa
#include <prettyprint.hpp>
void print() {cout << endl;} template<typename T, typename... Ts> void print(const T& value, const Ts&... values) {cout << value << ' ', print(values...);}
void debug() {cerr << endl;} template<typename T, typename... Ts> void debug(const T& value, const Ts&... values) {cerr << value << ' ', debug(values...);}
#endif

const int INF = numeric_limits<int>::max() - 1;
struct MinCostMaxFlow {
    struct Edge {
        int u, v, cap, f, cost; // f represent remaining flow
        Edge (int _u, int _v, int _cap, int _f, int _cost): u(_u), v(_v), cap(_cap), f(_f), cost(_cost) {};
    };
    priority_queue<pair<int, int> , vector<pair<int, int> >, greater<pair<int, int> > > pq;
    vector<Edge> e;
    vector<vector<int> > a;
    vector<int> dis, par;
    int n, S, T;
    bool dijkstra() {
        while (!pq.empty()) pq.pop();
        fill(dis.begin(), dis.end(), INF); fill(par.begin(), par.end(), -1);
        dis[S] = 0; pq.push({0, S});
        while (!pq.empty()) {
            auto [cud, u] = pq.top(); pq.pop();
            if (cud != dis[u]) continue;
            for (auto id : a[u]) {
                auto &t = e[id]; auto v = e[id].v;
                if (t.f && dis[v] > dis[u] + t.cost) {
                    dis[v] = dis[u] + t.cost;
                    par[v] = id;
                    pq.push({dis[v], v});
                }
            }
        }
        if (dis[T] != INF) return true;
        return false;
    }
    int dfs() {
        int delta = INF, u = T;
        while (u != S) {
            delta = min(delta, e[par[u]].f);
            u = e[par[u]].u;
        }
        u = T;
        while (u != S) {
            e[par[u]].f -= delta;
            e[par[u] ^ 1].f += delta;
            u = e[par[u]].u;
        }
        return delta;
    }
    void init(int _n, int _S, int _T) {
        n = _n; S = _S; T = _T; e.clear();
        a.assign(n, vector<int>()); dis.assign(n, 0); par.assign(n, 0);
    }
    void addEdge(int u, int v, int cap, int cost) {
        e.push_back({u, v, cap, cap, cost});
        e.push_back({v, u, 0, 0, -cost});
        a[u].push_back(e.size() - 2);
        a[v].push_back(e.size() - 1);
    }
    pair<int, int> solve() {
        pair<int, int> ret = {0, 0};
        while (dijkstra()) ret.fi += dfs();
        for (auto &rx : e) if (rx.cap > rx.f) ret.se += (rx.cap - rx.f) * rx.cost;
        return ret;
    }
} MCMF;

struct Task {
    int l, r, c;
    Task(int _l, int _t, int _c) {
        l = _l;
        r = l + _t - 1;
        c = _c;
    }
};
ostream &operator<<(ostream &os, Task X) {
    os << X.l << sp << X.r << sp << X.c;
    return os;
}

#define IN 0
#define OUT 1

int n, m;
int S = 0, T = 1;
vector<Task> tasks;
vector<int> all;

int gMa(int p) { // 0-based
    return T + p + 1;
}

int gTa(int p, bool type) {
    return T + m + 1 + p * 2 + type;
}

int gPiv(int p) {
    return T + m + 2 * n + p + 1;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    loop(i, 1, n) {
        int l, r, c;
        cin >> l >> r >> c;
        tasks.push_back(Task(l, r, c));
        all.push_back(tasks.back().l); all.push_back(tasks.back().r);
    }

    all.push_back(INF);
    sort(all.begin(), all.end()); all.resize(distance(all.begin(), unique(all.begin(), all.end())));
    for (auto &it : tasks) {
        it.l = lower_bound(all.begin(), all.end(), it.l) - all.begin();
        it.r = lower_bound(all.begin(), all.end(), it.r) - all.begin();
        // print(it.l, it.r);
    }

    MCMF.init(gPiv(all.size() - 1) + 1, S, T);
    loop(i, 0, m - 1) {
        MCMF.addEdge(S, gMa(i), 1, 0);
        MCMF.addEdge(gMa(i), gPiv(0), 1, 0);
    }
    loop(i, 0, all.size() - 1) {
        if (i != all.size() - 1)
            MCMF.addEdge(gPiv(i), gPiv(i + 1), INF, 0);
        else
            MCMF.addEdge(gPiv(i), T, INF, 0);
    }

    loop(i, 0, n - 1) {
        MCMF.addEdge(gPiv(tasks[i].l), gTa(i, IN), INF, 0);
        MCMF.addEdge(gTa(i, IN), gTa(i, OUT), 1, -tasks[i].c);
        MCMF.addEdge(gTa(i, OUT), gPiv(tasks[i].r + 1), INF, 0);
    }

    MCMF.solve();
    vector<bool> ans(n, 0);
    map<pair<int, int>, int> mark;
    for (auto it : MCMF.e) {
        mark[ {it.u, it.v}] = it.cap - it.f;
    }
    loop(i, 0, n - 1) {
        if (mark[ {gTa(i, IN), gTa(i, OUT)}] != 0) cout << 1 << sp;
        else cout << 0 << sp;
    }
    cout << endl;
}


/*input
10 2
699300217 520863246 750739
158802156 776305466 388177
556239371 900142068 187357
776489007 632844082 238502
361186251 188888255 483934
154509737 958411614 416129
777488390 894434905 348016
558588067 756129429 77163
938486404 462702730 640265
593570035 525346237 888643
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define bit(x,y) ((x>>y)&1)
#define loop(i,l,r) for(int i=(int)l; i<=(int)r; i++)
#define rloop(i,l,r) for(int i=(int)l; i>=(int)r; i--)
#ifdef UncleGrandpa
#include <prettyprint.hpp>
void print() {cout << endl;} template<typename T, typename... Ts> void print(const T& value, const Ts&... values) {cout << value << ' ', print(values...);}
void debug() {cerr << endl;} template<typename T, typename... Ts> void debug(const T& value, const Ts&... values) {cerr << value << ' ', debug(values...);}
#endif

const int INF = numeric_limits<int>::max() - 1;
struct MinCostMaxFlow {
    struct Edge {
        int u, v, cap, f, cost, id; // f is the remaining flow
        Edge (int _u, int _v, int _cap, int _f, int _cost, int _id): u(_u), v(_v), cap(_cap), f(_f), cost(_cost), id(_id) {};
    };
    queue<int> q;
    vector<Edge> e;
    vector<vector<int> > a;
    vector<int> dis, par;
    int n, S, T;
    bool SPFA() {
        fill(dis.begin(), dis.end(), INF); fill(par.begin(), par.end(), -1);
        dis[S] = 0; q.push(S);
        while (!q.empty()) {
            auto u = q.front(); q.pop();
            for (auto id : a[u]) {
                auto &t = e[id]; auto v = e[id].v;
                if (t.f && dis[v] > dis[u] + t.cost) {
                    dis[v] = dis[u] + t.cost;
                    par[v] = id;
                    q.push(v);
                }
            }
        }
        if (dis[T] != INF) return true;
        return false;
    }
    int dfs() {
        int delta = INF, u = T;
        while (u != S) {
            delta = min(delta, e[par[u]].f);
            u = e[par[u]].u;
        }
        u = T;
        while (u != S) {
            e[par[u]].f -= delta;
            e[par[u] ^ 1].f += delta;
            u = e[par[u]].u;
        }
        return delta;
    }
    void init(int _n, int _S, int _T) {
        n = _n; S = _S; T = _T; e.clear();
        a.assign(n, vector<int>()); dis.assign(n, 0); par.assign(n, 0);
    }
    void addEdge(int u, int v, int cap, int cost, int id) {
        e.push_back({u, v, cap, cap, cost, id});
        e.push_back({v, u, 0, 0, -cost, -1});
        a[u].push_back(e.size() - 2);
        a[v].push_back(e.size() - 1);
    }
    pair<int, int> solve() {
        pair<int, int> ret = {0, 0};
        while (SPFA()) ret.fi += dfs();
        for (auto &rx : e) if (rx.cap > rx.f) ret.se += (rx.cap - rx.f) * rx.cost;
        return ret;
    }
} MCMF;

struct Task {
    int l, r, c;
    Task(int _l, int _t, int _c) {
        l = _l;
        r = l + _t - 1;
        c = _c;
    }
};
ostream &operator<<(ostream &os, Task X) {
    os << X.l << sp << X.r << sp << X.c;
    return os;
}

int n, m;
int S = 0, T = 1;
vector<Task> tasks;
vector<int> all;

int gPiv(int p) {
    return T + p + 1;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef in1code
    freopen("1test.inp", "r", stdin);
#endif
    cin >> n >> m;
    loop(i, 1, n) {
        int l, r, c;
        cin >> l >> r >> c;
        tasks.push_back(Task(l, r, c));
        all.push_back(tasks.back().l); all.push_back(tasks.back().r);
    }

    all.push_back(INF);
    sort(all.begin(), all.end()); all.resize(distance(all.begin(), unique(all.begin(), all.end())));
    for (auto &it : tasks) {
        it.l = lower_bound(all.begin(), all.end(), it.l) - all.begin();
        it.r = lower_bound(all.begin(), all.end(), it.r) - all.begin();
    }

    MCMF.init(gPiv(all.size() - 1) + 1, S, T);
    MCMF.addEdge(S, gPiv(0), m, 0, -1);
    loop(i, 0, all.size() - 1) {
        if (i != all.size() - 1)
            MCMF.addEdge(gPiv(i), gPiv(i + 1), INF, 0, -1);
        else
            MCMF.addEdge(gPiv(i), T, INF, 0, -1);
    }

    loop(i, 0, n - 1) {
        MCMF.addEdge(gPiv(tasks[i].l), gPiv(tasks[i].r + 1), 1, -tasks[i].c, i);
    }

    MCMF.solve();
    vector<bool> ans(n, 0);
    map<int, int> mark;
    for (auto it : MCMF.e) {
        mark[it.id] = it.cap - it.f;
    }
    loop(i, 0, n - 1) {
        if (mark[i] != 0) cout << 1 << sp;
        else cout << 0 << sp;
    }
    cout << endl;
}


/*input
10 2
699300217 520863246 750739
158802156 776305466 388177
556239371 900142068 187357
776489007 632844082 238502
361186251 188888255 483934
154509737 958411614 416129
777488390 894434905 348016
558588067 756129429 77163
938486404 462702730 640265
593570035 525346237 888643
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define bit(x,y) ((x>>y)&1)
#define loop(i,l,r) for(int i=(int)l; i<=(int)r; i++)
#define rloop(i,l,r) for(int i=(int)l; i>=(int)r; i--)
#ifdef UncleGrandpa
#include <prettyprint.hpp>
void print() {cout << endl;} template<typename T, typename... Ts> void print(const T& value, const Ts&... values) {cout << value << ' ', print(values...);}
void debug() {cerr << endl;} template<typename T, typename... Ts> void debug(const T& value, const Ts&... values) {cerr << value << ' ', debug(values...);}
#endif

const int INF = 1e9 + 7;
struct MinCostMaxFlow {
    struct Edge {
        int u, v, cap, f, cost; // f represent remaining flow
        Edge (int _u, int _v, int _cap, int _f, int _cost): u(_u), v(_v), cap(_cap), f(_f), cost(_cost) {};
    };
    priority_queue<pair<int, int> , vector<pair<int, int> >, greater<pair<int, int> > > pq;
    vector<Edge> e;
    vector<vector<int> > a;
    vector<int> dis, par;
    int n, S, T;
    bool dijkstra() {
        while (!pq.empty()) pq.pop();
        fill(dis.begin(), dis.end(), INF); fill(par.begin(), par.end(), -1);
        dis[S] = 0; pq.push({0, S});
        while (!pq.empty()) {
            auto [cud, u] = pq.top(); pq.pop();
            if (cud != dis[u]) continue;
            for (auto id : a[u]) {
                auto &t = e[id]; auto v = e[id].v;
                if (t.f && dis[v] > dis[u] + t.cost) {
                    dis[v] = dis[u] + t.cost;
                    par[v] = id;
                    pq.push({dis[v], v});
                }
            }
        }
        if (dis[T] != INF) return true;
        return false;
    }
    int dfs() {
        int delta = INF, u = T;
        while (u != S) {
            delta = min(delta, e[par[u]].f);
            u = e[par[u]].u;
        }
        u = T;
        while (u != S) {
            e[par[u]].f -= delta;
            e[par[u] ^ 1].f += delta;
            u = e[par[u]].u;
        }
        return delta;
    }
    void init(int _n, int _S, int _T) {
        n = _n; S = _S; T = _T; e.clear();
        a.assign(n, vector<int>()); dis.assign(n, 0); par.assign(n, 0);
    }
    void addEdge(int u, int v, int cap, int cost) {
        e.push_back({u, v, cap, cap, cost});
        e.push_back({v, u, 0, 0, -cost});
        a[u].push_back(e.size() - 2);
        a[v].push_back(e.size() - 1);
    }
    pair<int, int> solve() {
        pair<int, int> ret = {0, 0};
        while (dijkstra()) ret.fi += dfs();
        for (auto &rx : e) if (rx.cap > rx.f) ret.se += (rx.cap - rx.f) * rx.cost;
        return ret;
    }
} MCMF;

struct Task {
    int l, r, c;
    Task(int _l, int _t, int _c) {
        l = _l;
        r = l + _t - 1;
        c = _c;
    }
};
ostream &operator<<(ostream &os, Task X) {
    os << X.l << sp << X.r << sp << X.c;
    return os;
}

#define IN 0
#define OUT 1

int n, m;
int S = 0, T = 1;
vector<Task> tasks;
vector<int> all;

int gMa(int p) { // 0-based
    return T + p + 1;
}

int gTa(int p, bool type) {
    return T + m + 1 + p * 2 + type;
}

int gPiv(int p) {
    return T + m + 2 * n + p + 2;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    loop(i, 1, n) {
        int l, r, c;
        cin >> l >> r >> c;
        tasks.push_back(Task(l, r, c));
        all.push_back(tasks.back().l); all.push_back(tasks.back().r);
    }

    all.push_back(INF);
    sort(all.begin(), all.end()); all.resize(distance(all.begin(), unique(all.begin(), all.end())));
    for (auto &it : tasks) {
        it.l = lower_bound(all.begin(), all.end(), it.l) - all.begin();
        it.r = lower_bound(all.begin(), all.end(), it.r) - all.begin();
        // print(it.l, it.r);
    }

    MCMF.init(gPiv(all.size() - 1) + 1, S, T);
    loop(i, 0, m - 1) {
        MCMF.addEdge(S, gMa(i), 1, 0);
        MCMF.addEdge(gMa(i), gPiv(0), 1, 0);
    }
    loop(i, 0, all.size() - 1) {
        if (i != all.size() - 1)
            MCMF.addEdge(gPiv(i), gPiv(i + 1), INF, 0);
        else
            MCMF.addEdge(gPiv(i), T, INF, 0);
    }

    loop(i, 0, n - 1) {
        MCMF.addEdge(gPiv(tasks[i].l), gTa(i, IN), INF, 0);
        MCMF.addEdge(gTa(i, IN), gTa(i, OUT), 1, -tasks[i].c);
        MCMF.addEdge(gTa(i, OUT), gPiv(tasks[i].r + 1), INF, 0);
    }

    MCMF.solve();
    vector<bool> ans(n, 0);
    map<pair<int, int>, int> mark;
    for (auto it : MCMF.e) {
        mark[ {it.u, it.v}] = it.cap - it.f;
    }
    loop(i, 0, n - 1) {
        if (mark[ {gTa(i, IN), gTa(i, OUT)}] != 0) cout << 1 << sp;
        else cout << 0 << sp;
    }
    cout << endl;
}


/*input
3 1
2 7 5
1 3 3
4 1 3
*/
#include <bits/stdc++.h>
using namespace std;
#define sp ' '
#define endl '\n'
#define fi first
#define se second
#define bit(x,y) ((x>>y)&1)
#define loop(i,l,r) for(int i=(int)l; i<=(int)r; i++)
#define rloop(i,l,r) for(int i=(int)l; i>=(int)r; i--)
#ifdef UncleGrandpa
#include <prettyprint.hpp>
void print() {cout << endl;} template<typename T, typename... Ts> void print(const T& value, const Ts&... values) {cout << value << ' ', print(values...);}
void debug() {cerr << endl;} template<typename T, typename... Ts> void debug(const T& value, const Ts&... values) {cerr << value << ' ', debug(values...);}
#endif

const int INF = numeric_limits<int>::max() / 2;
struct MinCostMaxFlow {
    struct Edge {
        int u, v, cap, f, cost; // f represent remaining flow
        Edge (int _u, int _v, int _cap, int _f, int _cost): u(_u), v(_v), cap(_cap), f(_f), cost(_cost) {};
    };
    priority_queue<pair<int, int> , vector<pair<int, int> >, greater<pair<int, int> > > pq;
    vector<Edge> e;
    vector<vector<int> > a;
    vector<int> dis, par;
    int n, S, T;
    bool dijkstra() {
        while (!pq.empty()) pq.pop();
        fill(dis.begin(), dis.end(), INF); fill(par.begin(), par.end(), -1);
        dis[S] = 0; pq.push({0, S});
        while (!pq.empty()) {
            auto [cud, u] = pq.top(); pq.pop();
            if (cud != dis[u]) continue;
            for (auto id : a[u]) {
                auto &t = e[id]; auto v = e[id].v;
                if (t.f && dis[v] > dis[u] + t.cost) {
                    dis[v] = dis[u] + t.cost;
                    par[v] = id;
                    pq.push({dis[v], v});
                }
            }
        }
        if (dis[T] != INF) return true;
        return false;
    }
    int dfs() {
        int delta = INF, u = T;
        while (u != S) {
            delta = min(delta, e[par[u]].f);
            u = e[par[u]].u;
        }
        u = T;
        while (u != S) {
            e[par[u]].f -= delta;
            e[par[u] ^ 1].f += delta;
            u = e[par[u]].u;
        }
        return delta;
    }
    void init(int _n, int _S, int _T) {
        n = _n; S = _S; T = _T; e.clear();
        a.assign(n, vector<int>()); dis.assign(n, 0); par.assign(n, 0);
    }
    void addEdge(int u, int v, int cap, int cost) {
        e.push_back({u, v, cap, cap, cost});
        e.push_back({v, u, 0, 0, -cost});
        a[u].push_back(e.size() - 2);
        a[v].push_back(e.size() - 1);
    }
    pair<int, int> solve() {
        pair<int, int> ret = {0, 0};
        while (dijkstra()) ret.fi += dfs();
        for (auto &rx : e) if (rx.cap > rx.f) ret.se += (rx.cap - rx.f) * rx.cost;
        return ret;
    }
} MCMF;

struct Task {
    int l, r, c;
    Task(int _l, int _t, int _c) {
        l = _l;
        r = l + _t - 1;
        c = _c;
    }
};
ostream &operator<<(ostream &os, Task X) {
    os << X.l << sp << X.r << sp << X.c;
    return os;
}

#define IN 0
#define OUT 1

int n, m;
int S = 0, T = 1;
vector<Task> tasks;
vector<int> all;

int gMa(int p) { // 0-based
    return T + p + 1;
}

int gTa(int p, bool type) {
    return T + m + 1 + p * 2 + type;
}

int gPiv(int p) {
    return T + m + 2 * n + p + 1;
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    cin >> n >> m;
    loop(i, 1, n) {
        int l, r, c;
        cin >> l >> r >> c;
        tasks.push_back(Task(l, r, c));
        all.push_back(tasks.back().l); all.push_back(tasks.back().r);
    }

    all.push_back(INF);
    sort(all.begin(), all.end()); all.resize(distance(all.begin(), unique(all.begin(), all.end())));
    for (auto &it : tasks) {
        it.l = lower_bound(all.begin(), all.end(), it.l) - all.begin();
        it.r = lower_bound(all.begin(), all.end(), it.r) - all.begin();
        // print(it.l, it.r);
    }

    MCMF.init(gPiv(all.size() - 1) + 1, S, T);
    loop(i, 0, m - 1) {
        MCMF.addEdge(S, gMa(i), 1, 0);
        MCMF.addEdge(gMa(i), gPiv(0), 1, 0);
    }
    loop(i, 0, all.size() - 1) {
        if (i != all.size() - 1)
            MCMF.addEdge(gPiv(i), gPiv(i + 1), INF, 0);
        else
            MCMF.addEdge(gPiv(i), T, INF, 0);
    }

    loop(i, 0, n - 1) {
        MCMF.addEdge(gPiv(tasks[i].l), gTa(i, IN), INF, 0);
        MCMF.addEdge(gTa(i, IN), gTa(i, OUT), 1, -tasks[i].c);
        MCMF.addEdge(gTa(i, OUT), gPiv(tasks[i].r + 1), INF, 0);
    }

    MCMF.solve();
    vector<bool> ans(n, 0);
    map<pair<int, int>, int> mark;
    for (auto it : MCMF.e) {
        mark[ {it.u, it.v}] = it.cap - it.f;
    }
    loop(i, 0, n - 1) {
        if (mark[ {gTa(i, IN), gTa(i, OUT)}] != 0) cout << 1 << sp;
        else cout << 0 << sp;
    }
    cout << endl;
}


#include<bits/stdc++.h>
using namespace std;

const int maxn=1e3+5;
const int INF=1e9;

struct Node {
	int s,t,c;
} a[maxn];

struct Edge {
	int from,to,cap,flow,cost,id;
};

struct MCMF {
	int n;
	vector<Edge> es;
	vector<int> G[maxn];
	int inq[maxn];
	int dis[maxn];
	int pre[maxn];
	int cc[maxn];
	void init(int n) {
		this->n=n;
		for(int i=0; i<=n; i++)G[i].clear();
		es.clear();
	}

	void addEdge(int f,int t,int cap,int cost,int id=0) {
		es.push_back((Edge) {
			f,t,cap,0,cost,id
		});
		es.push_back((Edge) {
			t,f,0,0,-cost,id
		});
		int m=es.size();
		G[f].push_back(m-2);
		G[t].push_back(m-1);
	}

	bool spfa(int s,int t,int &flow,int& cost) {
		for(int i=0; i<=n; i++) dis[i]=-INF;
		memset(inq,0,sizeof(inq));
		dis[s]=0;
		inq[s]=1;
		pre[s]=0;
		cc[s]=INF;
		queue<int> Q;
		Q.push(s);
		while(!Q.empty()) {
			int u=Q.front();
			Q.pop();
			inq[u]=0;
			for(int i=0; i<G[u].size(); i++) {
				Edge& e= es[G[u][i]];
				if(e.cap>e.flow && dis[e.to]<dis[u]+e.cost) {
					dis[e.to]=dis[u]+e.cost;
					pre[e.to]=G[u][i];
					cc[e.to]=min(cc[u],e.cap-e.flow);
					if(!inq[e.to]) {
						Q.push(e.to);
						inq[e.to]=1;
					}
				}
			}
		}
		if(dis[t]==-INF) return false;
		flow+=cc[t];
		cost+=dis[t]*cc[t];
		int u=t;
		while(u!=s) {
			es[pre[u]].flow+=cc[t];
			es[pre[u]^1].flow-=cc[t];
			u=es[pre[u]].from;
		}

		return true;
	}
	int minCost(int s,int t) {
		int flow=0,cost=0;
		while(spfa(s,t,flow,cost));
		return cost;
	}
} mcmf;

map<int,int> mp;
bool res[maxn];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	vector<int> mtime;
	for(int i=1; i<=n; i++) {
		cin>>a[i].s>>a[i].t>>a[i].c;
		a[i].t+=a[i].s;
		mp[a[i].s]=0;
		mp[a[i].t]=0;
	}
	int cnt=0;
	for(auto &e:mp) e.second=++cnt;
	for(int i=1;i<=n;i++){
		int x=mp[a[i].s];
		int y=mp[a[i].t];
		a[i].s=x;
		a[i].t=y;
	}
	mcmf.init(cnt+1);
	for(int i=0;i<=cnt;i++){
		mcmf.addEdge(i,i+1,k,0);
	}
	for(int i=1;i<=n;i++){
		mcmf.addEdge(a[i].s,a[i].t,1,a[i].c,i);
	}
	mcmf.minCost(0,cnt+1);
	for(int i=2;i<mcmf.es.size();i+=2){
		Edge& e=mcmf.es[i];
		if(e.flow==e.cap&&e.id!=0){
			res[e.id]=1;
		}
	}
	for(int i=1;i<=n;i++){
		cout<<res[i]<<' ';
	}
	cout<<endl;

	return 0;
}


#include<bits/stdc++.h>
using namespace std;

const int maxn=1e6+5;
const int INF=1e9;

struct Node {
	int s,t,c;
} a[maxn];

struct Edge {
	int from,to,cap,flow,cost,id;
};

struct MCMF {
	int n;
	vector<Edge> es;
	vector<int> G[maxn];
	int inq[maxn];
	int dis[maxn];
	int pre[maxn];
	int cc[maxn];
	void init(int n) {
		this->n=n;
		for(int i=0; i<=n; i++)G[i].clear();
		es.clear();
	}

	void addEdge(int f,int t,int cap,int cost,int id=0) {
		es.push_back((Edge) {
			f,t,cap,0,cost,id
		});
		es.push_back((Edge) {
			t,f,0,0,-cost,id
		});
		int m=es.size();
		G[f].push_back(m-2);
		G[t].push_back(m-1);
	}

	bool spfa(int s,int t,int &flow,int& cost) {
		for(int i=0; i<=n; i++) dis[i]=-INF;
		memset(inq,0,sizeof(inq));
		dis[s]=0;
		inq[s]=1;
		pre[s]=0;
		cc[s]=INF;
		queue<int> Q;
		Q.push(s);
		while(!Q.empty()) {
			int u=Q.front();
			Q.pop();
			inq[u]=0;
			for(int i=0; i<G[u].size(); i++) {
				Edge& e= es[G[u][i]];
				if(e.cap>e.flow && dis[e.to]<dis[u]+e.cost) {
					dis[e.to]=dis[u]+e.cost;
					pre[e.to]=G[u][i];
					cc[e.to]=min(cc[u],e.cap-e.flow);
					if(!inq[e.to]) {
						Q.push(e.to);
						inq[e.to]=1;
					}
				}
			}
		}
		if(dis[t]==-INF) return false;
		flow+=cc[t];
		cost+=dis[t]*cc[t];
		int u=t;
		while(u!=s) {
			es[pre[u]].flow+=cc[t];
			es[pre[u]^1].flow-=cc[t];
			u=es[pre[u]].from;
		}

		return true;
	}
	int minCost(int s,int t) {
		int flow=0,cost=0;
		while(spfa(s,t,flow,cost));
		return cost;
	}
} mcmf;

map<int,int> mp;
bool res[maxn];

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	vector<int> mtime;
	for(int i=1; i<=n; i++) {
		cin>>a[i].s>>a[i].t>>a[i].c;
		a[i].t+=a[i].s;
		mp[a[i].s]=0;
		mp[a[i].t]=0;
	}
	int cnt=0;
	for(auto &e:mp) e.second=++cnt;
	for(int i=1;i<=n;i++){
		int x=mp[a[i].s];
		int y=mp[a[i].t];
		a[i].s=x;
		a[i].t=y;
	}
	mcmf.init(cnt+1);
	for(int i=0;i<=cnt;i++){
		mcmf.addEdge(i,i+1,k,0);
	}
	for(int i=1;i<=n;i++){
		mcmf.addEdge(a[i].s,a[i].t,1,a[i].c,i);
	}
	mcmf.minCost(0,cnt+1);
	for(int i=2;i<mcmf.es.size();i+=2){
		Edge& e=mcmf.es[i];
		if(e.flow==e.cap&&e.id!=0){
			res[e.id]=1;
		}
	}
	for(int i=1;i<=n;i++){
		cout<<res[i]<<' ';
	}
	cout<<endl;

	return 0;
}


#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll INF = INT32_MAX;

struct Edge {
	int u, v, cap, flow, cost;
};

vector<vector<int>> g;
vector<Edge> ed;
vector<int> d, pot, par;
int n, start, endd;

void init(int s, int st, int en) {
	n = s;
	start = st;
	endd = en;
	g.resize(n);
	d.resize(n);
	pot.resize(n);
	par.resize(n);
}

void add_edge(int u, int v, int cap, int cost) {
	int p = (int)ed.size();
	ed.push_back({ u, v, cap, 0, cost });
	ed.push_back({ v, u, 0, 0, -cost });
	g[u].push_back(p);
	g[v].push_back(p + 1);
}

bool dijkstra() {
	fill(d.begin(), d.end(), INF);
	fill(par.begin(), par.end(), -1);
	d[start] = 0;
	set<pair<int, int>> s;
	s.insert({ 0, start });
	while (!s.empty()) {
		auto cur = *s.begin();
		s.erase(s.begin());
		int v = cur.second;
		for (auto ind : g[v]) {
			if (ed[ind].cap == ed[ind].flow)continue;
			int w = ed[ind].cost + pot[ed[ind].u] - pot[ed[ind].v];
			if (d[v] + w < d[ed[ind].v]) {
				s.erase(make_pair(d[ed[ind].v], ed[ind].v));
				par[ed[ind].v] = ind;
				d[ed[ind].v] = d[v] + w;
				s.insert({ d[ed[ind].v], ed[ind].v });
			}
		}
	}
	return d[endd] < INF;
}

vector<int> top, used;
void dfs(int v) {
	used[v] = 1;
	for (auto i : g[v]) {
		if (!used[ed[i].v]) {
			dfs(ed[i].v);
		}
	}
	top.push_back(v);
}

void ford() {
	fill(pot.begin(), pot.end(), INF);
	pot[start] = 0;
	used.resize(n);
	dfs(0);
	reverse(top.begin(), top.end());
	for (int i = 0; i < top.size(); i++) {
		for (auto u : g[top[i]]) {
			pot[ed[u].v] = min(pot[ed[i].v], pot[ed[i].u] + ed[i].cost);
		}
	}
}

vector<int> restore_path() {
	vector<int> path;
	for (int i = endd; par[i] != -1; i = ed[par[i]].u) {
		path.push_back(par[i]);
	}
	return path;
}

int solve() {
	ford();
	int ans = 0;
	while (dijkstra()) {
		vector<int> path = restore_path();
		int add = INF;
		for (auto i : path)add = min(add, ed[i].cap - ed[i].flow);
		for (auto i : path) {
			ans += add * ed[i].cost;
			ed[i].flow += add;
			ed[i ^ 1].flow -= add;
		}
		for (int i = 0; i < n; i++)pot[i] += d[i];
	}
	return ans;
}

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int k, m;
	cin >> k >> m;
	vector<int> all, s(k), t(k), c(k);
	for (int i = 0; i < k; i++) {
		cin >> s[i] >> t[i] >> c[i];
		all.push_back(s[i]);
		all.push_back(s[i] + t[i]);
	}
	sort(all.begin(), all.end());
	all.resize(unique(all.begin(), all.end()) - all.begin());
	init(all.size() + 2, all.size(), all.size() + 1);
	add_edge(start, 0, m, 0);
	add_edge(all.size() - 1, endd, m, 0);
	for (int i = 0; i < (int)all.size() - 1; i++) {
		add_edge(i, i + 1, m, 0);
	}
	vector<int> eid(k);
	for (int i = 0; i < k; i++)
	{
		int a = lower_bound(all.begin(), all.end(), s[i]) - all.begin();
		int b = lower_bound(all.begin(), all.end(), s[i] + t[i]) - all.begin();
		eid[i] = g[a].size();
		add_edge(a, b, 1, -c[i]);
	}
	int res = solve();
	for (int i = 0; i < k; i++) {
		int a = lower_bound(all.begin(), all.end(), s[i]) - all.begin();
		cout << ed[g[a][eid[i]]].flow << " ";
	}
}


#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll INF = INT32_MAX;

struct Edge {
	int u, v, cap, flow, cost;
};

vector<vector<int>> g;
vector<Edge> ed;
vector<int> d, pot, par;
int n, start, endd;

void init(int s, int st, int en) {
	n = s;
	start = st;
	endd = en;
	g.resize(n);
	d.resize(n);
	pot.resize(n);
	par.resize(n);
}

void add_edge(int u, int v, int cap, int cost) {
	int p = (int)ed.size();
	ed.push_back({ u, v, cap, 0, cost });
	ed.push_back({ v, u, 0, 0, -cost });
	g[u].push_back(p);
	g[v].push_back(p + 1);
}

priority_queue <pair <int, int> > qu;
bool dijkstra() {
	fill(d.begin(), d.end(), INF);
	fill(par.begin(), par.end(), -1);
	d[start] = 0;
	qu.push(make_pair(-d[start], start));
	while (!qu.empty()){
		int v = qu.top().second;
		int cd = -qu.top().first;
		qu.pop();
		if (d[v] != cd)
			continue;
		for (auto i : g[v])
		{
			if (ed[i].flow == ed[i].cap)
				continue;
			int nv = ed[i].v;
			int nd = cd + ed[i].cost - pot[nv] + pot[v];

			if (nd < d[nv])
			{
				d[nv] = nd;
				par[nv] = i;
				qu.push(make_pair(-d[nv], nv));
			}
		}
	}
	return d[endd] < INF;
}

vector<int> restore_path() {
	vector<int> path;
	for (int i = endd; par[i] != -1; i = ed[par[i]].u) {
		path.push_back(par[i]);
	}
	return path;
}

void ford() {
	fill(pot.begin(), pot.end(), INF);
	pot[start] = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < ed.size(); j++) {
			if (pot[ed[j].u] < INF) {
				pot[ed[j].v] = min(pot[ed[j].v], pot[ed[j].u] + ed[j].cost);
			}
		}
	}
}

int solve() {
	ford();
	int ans = 0;
	while (dijkstra()) {
		vector<int> path = restore_path();
		int add = INF;
		for (auto i : path)add = min(add, ed[i].cap - ed[i].flow);
		for (auto i : path) {
			ans += add * ed[i].cost;
			ed[i].flow += add;
			ed[i ^ 1].flow -= add;
		}
		for (int i = 0; i < n; i++)pot[i] += d[i];
	}
	return ans;
}

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int k, m;
	cin >> k >> m;
	vector<int> all, s(k), t(k), c(k);
	for (int i = 0; i < k; i++) {
		cin >> s[i] >> t[i] >> c[i];
		all.push_back(s[i]);
		all.push_back(s[i] + t[i]);
	}
	sort(all.begin(), all.end());
	all.resize(unique(all.begin(), all.end()) - all.begin());
	init(all.size() + 2, all.size(), all.size() + 1);
	add_edge(start, 0, m, 0);
	add_edge(all.size() - 1, endd, m, 0);
	for (int i = 0; i < (int)all.size() - 1; i++) {
		add_edge(i, i + 1, m, 0);
	}
	vector<int> eid(k);
	for (int i = 0; i < k; i++)
	{
		int a = lower_bound(all.begin(), all.end(), s[i]) - all.begin();
		int b = lower_bound(all.begin(), all.end(), s[i] + t[i]) - all.begin();
		eid[i] = g[a].size();
		add_edge(a, b, 1, -c[i]);
	}
	int res = solve();
	for (int i = 0; i < k; i++) {
		int a = lower_bound(all.begin(), all.end(), s[i]) - all.begin();
		cout << ed[g[a][eid[i]]].flow << " ";
	}
}


#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll INF = INT32_MAX;

struct Edge {
	int u, v, cap, flow, cost;
};

vector<vector<int>> g;
vector<Edge> ed;
vector<int> d, pot, par;
int n, start, endd;

void init(int s, int st, int en) {
	n = s;
	start = st;
	endd = en;
	g.resize(n);
	d.resize(n);
	pot.resize(n);
	par.resize(n);
}

void add_edge(int u, int v, int cap, int cost) {
	int p = (int)ed.size();
	ed.push_back({ u, v, cap, 0, cost });
	ed.push_back({ v, u, 0, 0, -cost });
	g[u].push_back(p);
	g[v].push_back(p + 1);
}

bool dijkstra() {
	fill(d.begin(), d.end(), INF);
	fill(par.begin(), par.end(), -1);
	d[start] = 0;
	set<pair<int, int>> s;
	s.insert({ 0, start });
	while (!s.empty()) {
		auto cur = *s.begin();
		s.erase(s.begin());
		int v = cur.second;
		for (auto ind : g[v]) {
			if (ed[ind].cap == ed[ind].flow)continue;
			int w = ed[ind].cost + pot[ed[ind].u] - pot[ed[ind].v];
			if (d[v] + w < d[ed[ind].v]) {
				s.erase(make_pair(d[ed[ind].v], ed[ind].v));
				par[ed[ind].v] = ind;
				d[ed[ind].v] = d[v] + w;
				s.insert({ d[ed[ind].v], ed[ind].v });
			}
		}
	}
	return d[endd] < INF;
}

vector<int> top, used;
void dfs(int v) {
	used[v] = 1;
	for (auto i : g[v]) {
		if (!used[ed[i].v]) {
			dfs(ed[i].v);
		}
	}
	top.push_back(v);
}

void ford() {
	fill(pot.begin(), pot.end(), INF);
	pot[start] = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < ed.size(); j++) {
			if (pot[ed[j].u] < INF) {
				pot[ed[j].v] = min(pot[ed[j].v], pot[ed[j].u] + ed[j].cost);
			}
		}
	}
}

vector<int> restore_path() {
	vector<int> path;
	for (int i = endd; par[i] != -1; i = ed[par[i]].u) {
		path.push_back(par[i]);
	}
	return path;
}

int solve() {
	ford();
	int ans = 0;
	while (dijkstra()) {
		vector<int> path = restore_path();
		int add = INF;
		for (auto i : path)add = min(add, ed[i].cap - ed[i].flow);
		for (auto i : path) {
			ans += add * ed[i].cost;
			ed[i].flow += add;
			ed[i ^ 1].flow -= add;
		}
		for (int i = 0; i < n; i++)pot[i] += d[i];
	}
	return ans;
}

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int k, m;
	cin >> k >> m;
	vector<int> all, s(k), t(k), c(k);
	for (int i = 0; i < k; i++) {
		cin >> s[i] >> t[i] >> c[i];
		all.push_back(s[i]);
		all.push_back(s[i] + t[i]);
	}
	sort(all.begin(), all.end());
	all.resize(unique(all.begin(), all.end()) - all.begin());
	init(all.size() + 2, all.size(), all.size() + 1);
	add_edge(start, 0, m, 0);
	add_edge(all.size() - 1, endd, m, 0);
	for (int i = 0; i < (int)all.size() - 1; i++) {
		add_edge(i, i + 1, m, 0);
	}
	vector<int> eid(k);
	for (int i = 0; i < k; i++)
	{
		int a = lower_bound(all.begin(), all.end(), s[i]) - all.begin();
		int b = lower_bound(all.begin(), all.end(), s[i] + t[i]) - all.begin();
		eid[i] = g[a].size();
		add_edge(a, b, 1, -c[i]);
	}
	int res = solve();
	for (int i = 0; i < k; i++) {
		int a = lower_bound(all.begin(), all.end(), s[i]) - all.begin();
		cout << ed[g[a][eid[i]]].flow << " ";
	}
}


#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll INF = INT32_MAX;

struct Edge {
	int u, v, cap, flow, cost;
};

vector<vector<int>> g;
vector<Edge> ed;
vector<int> d, pot, par;
int n, start, endd;

void init(int s, int st, int en) {
	n = s;
	start = st;
	endd = en;
	g.resize(n);
	d.resize(n);
	pot.resize(n);
	par.resize(n);
}

void add_edge(int u, int v, int cap, int cost) {
	int p = (int)ed.size();
	ed.push_back({ u, v, cap, 0, cost });
	ed.push_back({ v, u, 0, 0, -cost });
	g[u].push_back(p);
	g[v].push_back(p + 1);
}

bool dijkstra() {
	fill(d.begin(), d.end(), INF);
	fill(par.begin(), par.end(), -1);
	d[start] = 0;
	set<pair<int, int>> s;
	s.insert({ 0, start });
	while (!s.empty()) {
		auto cur = *s.begin();
		s.erase(s.begin());
		int v = cur.second;
		for (auto ind : g[v]) {
			if (ed[ind].cap == ed[ind].flow)continue;
			int w = ed[ind].cost + pot[ed[ind].u] - pot[ed[ind].v];
			if (d[v] + w < d[ed[ind].v]) {
				s.erase(make_pair(d[ed[ind].v], ed[ind].v));
				par[ed[ind].v] = ind;
				d[ed[ind].v] = d[v] + w;
				s.insert({ d[ed[ind].v], ed[ind].v });
			}
		}
	}
	return d[endd] < INF;
}

vector<int> top, used;
void dfs(int v) {
	used[v] = 1;
	for (auto i : g[v]) {
		if (!used[ed[i].v]) {
			dfs(ed[i].v);
		}
	}
	top.push_back(v);
}

void ford() {
	fill(pot.begin(), pot.end(), INF);
	pot[start] = 0;
	used.resize(n);
	dfs(0);
	reverse(top.begin(), top.end());
	for (int i = 0; i < top.size(); i++) {
		for (auto u : g[top[i]]) {
			pot[ed[u].v] = min(pot[ed[i].v], pot[ed[i].u] + ed[i].cost);
		}
	}
}

vector<int> restore_path() {
	vector<int> path;
	for (int i = endd; par[i] != -1; i = ed[par[i]].u) {
		path.push_back(par[i]);
	}
	return path;
}

int solve() {
	ford();
	int ans = 0;
	while (dijkstra()) {
		vector<int> path = restore_path();
		int add = INF;
		for (auto i : path)add = min(add, ed[i].cap - ed[i].flow);
		for (auto i : path) {
			ans += add * ed[i].cost;
			ed[i].flow += add;
			ed[i ^ 1].flow -= add;
		}
		for (int i = 0; i < n; i++)pot[i] += d[i];
	}
	return ans;
}

struct kek {
	int a, b, c;
};

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int k, m;
	cin >> k >> m;
	vector<kek> a(k);
	for (int i = 0; i < k; i++) {
		cin >> a[i].a >> a[i].b >> a[i].c;
		a[i].b = a[i].a + a[i].b - 1;
	}
	init(2 * k + 3, 0, 2 * k + 2);
	for (int i = 0; i < k; i++) {
		add_edge(2 * i + 2, 2 * i + 3, 1, -a[i].c);
	}
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < k; j++) {
			if (a[i].a > a[j].b) {
				add_edge(2 * j + 3, 2 * i + 2, 1, 0);
			}
		}
	}

	for (int i = 0; i < k; i++) {
		add_edge(1, 2 * i + 2, 1, 0);
		add_edge(2 * i + 3, 2 * k + 2, 1, 0);
	}
	add_edge(0, 1, m, 0);
	int res = solve();
	vector<int> ans(k, 0);
	for (int i = 0; i < 2 * k; i += 2) {
		if (ed[i].flow == 1)ans[i / 2] = 1;
	}
	for (auto i : ans)cout << i << " ";
}


#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll INF = INT32_MAX;

struct Edge {
	int u, v, cap, flow, cost;
};

vector<vector<int>> g;
vector<Edge> ed;
vector<int> d, pot, par;
int n, start, endd;

void init(int s, int st, int en) {
	n = s;
	start = st;
	endd = en;
	g.resize(n);
	d.resize(n);
	pot.resize(n);
	par.resize(n);
}

void add_edge(int u, int v, int cap, int cost) {
	int p = (int)ed.size();
	ed.push_back({ u, v, cap, 0, cost });
	ed.push_back({ v, u, 0, 0, -cost });
	g[u].push_back(p);
	g[v].push_back(p + 1);
}

bool dijkstra() {
	fill(d.begin(), d.end(), INF);
	fill(par.begin(), par.end(), -1);
	d[start] = 0;
	set<pair<int, int>> s;
	s.insert({ 0, start });
	while (!s.empty()) {
		auto cur = *s.begin();
		s.erase(s.begin());
		int v = cur.second;
		for (auto ind : g[v]) {
			if (ed[ind].cap == ed[ind].flow)continue;
			int w = ed[ind].cost + pot[ed[ind].u] - pot[ed[ind].v];
			if (d[v] + w < d[ed[ind].v]) {
				s.erase(make_pair(d[ed[ind].v], ed[ind].v));
				par[ed[ind].v] = ind;
				d[ed[ind].v] = d[v] + w;
				s.insert({ d[ed[ind].v], ed[ind].v });
			}
		}
	}
	return d[endd] < INF;
}

void ford() {
	fill(pot.begin(), pot.end(), INF);
	pot[start] = 0;
	for (int i = 0; i < n - 1; i++) {
		for (int j = 0; j < ed.size(); j++) {
			if (pot[ed[j].u] < INF) {
				pot[ed[j].v] = min(pot[ed[j].v], pot[ed[j].u] + ed[j].cost);
			}
		}
	}
}

vector<int> restore_path() {
	vector<int> path;
	for (int i = endd; par[i] != -1; i = ed[par[i]].u) {
		path.push_back(par[i]);
	}
	return path;
}

int solve() {
	ford();
	int ans = 0;
	while (dijkstra()) {
		vector<int> path = restore_path();
		int add = INF;
		for (auto i : path)add = min(add, ed[i].cap - ed[i].flow);
		for (auto i : path) {
			ans += add * ed[i].cost;
			ed[i].flow += add;
			ed[i ^ 1].flow -= add;
		}
		for (int i = 0; i < n; i++)pot[i] += d[i];
	}
	return ans;
}

vector<ll> used;
vector<vector<int>> ans;
int dfs2(int v, int fl = INT32_MAX) {
	used[v] = 1;
	if (v == endd) {
		return fl;
	}
	for (auto ind : g[v]) {
		if (!used[ed[ind].v] && ed[ind].flow > 0) {
			int find = dfs2(ed[ind].v, min(fl, ed[ind].flow));
			if (find > 0) {
				ed[ind].flow -= find;
				ans.back().push_back(ind / 4 + 1);
				return find;
			}
		}
	}
	return 0;
}

struct kek {
	int a, b, c;
};

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int k, m;
	cin >> k >> m;
	vector<kek> a(k);
	for (int i = 0; i < k; i++) {
		cin >> a[i].a >> a[i].b >> a[i].c;
		a[i].b = a[i].a + a[i].b - 1;
	}
	init(k + 3, 0, k + 2);
	for (int i = 0; i < k; i++) {
		for (int j = 0; j < k; j++) {
			if (a[i].a > a[j].b) {
				add_edge(j + 2, i + 2, 1, -a[i].c);
			}
		}
	}

	for (int i = 0; i < k; i++) {
		add_edge(1, i + 2, 1, 0);
		add_edge(i + 2, k + 2, 1, -a[i].c);
	}
	add_edge(0, 1, m, 0);
	int res = solve();
	vector<int> ans(k, 0);
	for (auto i : ed) {
		//cout << i.u << " " << i.v << " " << i.flow << "\n";
		if (i.u >= 2 && i.flow == 1) {
			ans[i.u - 2] = 1;
		}
	}
	for (auto i : ans)cout << i << " ";
}


#include <iostream>
#include <set>
#include <map>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <climits>
#include <math.h>
#include <cassert>
#include <unordered_map>
#include <chrono>
#include <random>
#include <ctime>
using namespace std;
#pragma warning(disable : 4996)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const ld PI = 3.14159265358979323846;
const ll MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll INF = INT32_MAX;

struct Edge {
	int u, v, cap, flow, cost;
};

vector<vector<int>> g;
vector<Edge> ed;
vector<int> d, pot, par;
int n, start, endd;

void init(int s, int st, int en) {
	n = s;
	start = st;
	endd = en;
	g.resize(n);
	d.resize(n);
	pot.resize(n);
	par.resize(n);
}

void add_edge(int u, int v, int cap, int cost) {
	int p = (int)ed.size();
	ed.push_back({ u, v, cap, 0, cost });
	ed.push_back({ v, u, 0, 0, -cost });
	g[u].push_back(p);
	g[v].push_back(p + 1);
}

priority_queue <pair <int, int> > qu;
bool dijkstra() {
	fill(d.begin(), d.end(), INF);
	fill(par.begin(), par.end(), -1);
	d[start] = 0;
	qu.push(make_pair(-d[start], start));
	while (!qu.empty()){
		int v = qu.top().second;
		int cd = -qu.top().first;
		qu.pop();
		if (d[v] != cd)
			continue;
		for (auto i : g[v])
		{
			if (ed[i].flow == ed[i].cap)
				continue;
			int nv = ed[i].v;
			int nd = cd + ed[i].cost - pot[nv] + pot[v];

			if (nd < d[nv])
			{
				d[nv] = nd;
				par[nv] = i;
				qu.push(make_pair(-d[nv], nv));
			}
		}
	}
	return d[endd] < INF;
}

vector<int> restore_path() {
	vector<int> path;
	for (int i = endd; par[i] != -1; i = ed[par[i]].u) {
		path.push_back(par[i]);
	}
	return path;
}

void ford() {
	fill(pot.begin(), pot.end(), INF);
	pot[start] = 0;
	for (int it = 0; it < n; it++) {
		for (int i = 0; i < n; i++)	{
			for (auto j : g[i]) {
				if (ed[j].flow == ed[j].cap)
					continue;
				int cCost = ed[j].cost;
				int nv = ed[j].v;
				pot[nv] = min(pot[nv], pot[i] + cCost);
			}
		}
	}
}

int solve() {
	ford();
	int ans = 0;
	while (dijkstra()) {
		vector<int> path = restore_path();
		int add = INF;
		for (auto i : path)add = min(add, ed[i].cap - ed[i].flow);
		for (auto i : path) {
			ans += add * ed[i].cost;
			ed[i].flow += add;
			ed[i ^ 1].flow -= add;
		}
		for (int i = 0; i < n; i++)pot[i] += d[i];
	}
	return ans;
}

int main() {
#ifdef _DEBUG
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	srand(time(0));
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int k, m;
	cin >> k >> m;
	vector<int> all, s(k), t(k), c(k);
	for (int i = 0; i < k; i++) {
		cin >> s[i] >> t[i] >> c[i];
		all.push_back(s[i]);
		all.push_back(s[i] + t[i]);
	}
	sort(all.begin(), all.end());
	all.resize(unique(all.begin(), all.end()) - all.begin());
	init(all.size() + 2, all.size(), all.size() + 1);
	add_edge(start, 0, m, 0);
	add_edge(all.size() - 1, endd, m, 0);
	for (int i = 0; i < (int)all.size() - 1; i++) {
		add_edge(i, i + 1, m, 0);
	}
	vector<int> eid(k);
	for (int i = 0; i < k; i++)
	{
		int a = lower_bound(all.begin(), all.end(), s[i]) - all.begin();
		int b = lower_bound(all.begin(), all.end(), s[i] + t[i]) - all.begin();
		eid[i] = g[a].size();
		add_edge(a, b, 1, -c[i]);
	}
	int res = solve();
	for (int i = 0; i < k; i++) {
		int a = lower_bound(all.begin(), all.end(), s[i]) - all.begin();
		cout << ed[g[a][eid[i]]].flow << " ";
	}
}