#include <bits/stdc++.h>

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define fst first
#define snd second
#define mset(a, b) memset(a, b, sizeof(a))

typedef long long ll;

typedef ll tf;
typedef ll tc;
const tf INF=1e9;
struct MCF{
	int n;
	vector<tc> prio, pot; vector<tf> curflow; vector<int> prevedge,prevnode;
	priority_queue<pair<tc, int>, vector<pair<tc, int>>, greater<pair<tc, int>>> q;
	struct edge{int to, rev; tf f, cap; tc cost;};
	vector<vector<edge>> g;
	MCF(int n):n(n),prio(n),curflow(n),prevedge(n),prevnode(n),pot(n),g(n){}
	void add_edge(int s, int t, tf cap, tc cost) {
    // cout << s << " " << t << " " << cap << " " << cost << endl;
		g[s].pb((edge){t,SZ(g[t]),0,cap,cost});
		g[t].pb((edge){s,SZ(g[s])-1,0,0,-cost});
	}
	pair<tf,tc> get_flow(int s, int t) {
		tf flow=0; tc flowcost=0;
    // cout << s << " " << t << endl;
		while(1){
			q.push({0, s});
			fill(ALL(prio),INF);
			prio[s]=0; curflow[s]=INF;
			while(!q.empty()) {
				auto cur=q.top();
				tc d=cur.fst;
        int u=cur.snd;
				q.pop();
				if(d!=prio[u]) continue;
				for(int i=0; i<SZ(g[u]); ++i) {
					edge &e=g[u][i];
					int v=e.to;
					if(e.cap<=e.f) continue;
					tc nprio=prio[u]+e.cost+pot[u]-pot[v];
					if(prio[v]>nprio) {
						prio[v]=nprio;
						q.push({nprio, v});
						prevnode[v]=u; prevedge[v]=i;
						curflow[v]=min(curflow[u], e.cap-e.f);
					}
				}
			}
			if(prio[t]==INF) break;
			fore(i,0,n) pot[i]+=prio[i];
			tf df=min(curflow[t], INF-flow);
			flow+=df;
			for(int v=t; v!=s; v=prevnode[v]) {
				edge &e=g[prevnode[v]][prevedge[v]];
				e.f+=df; g[v][e.rev].f-=df;
				flowcost+=df*e.cost;
			}
		}
		return {flow,flowcost};
	}
};

struct task{int s, t,c,id;};

int main() {
  int n, k; cin >> n >> k;
  MCF mcf(2 * n + 3); mcf.add_edge(2 * n, 2 * n + 1, k, 0);
  vector<task> ts;
  fore(i, 0, n) {
    int s, t , c; cin >> s >> t >> c;
    ts.pb({s, t, c, i});
  }
  sort(ts.begin(), ts.end(), [](const task& a, const task& b)->bool{
    return a.s < b.s;
  });
  fore(i, 0, n) {
    mcf.add_edge(2 * n + 1, i, INF, 0);
    mcf.add_edge(i, i + n, 1, -ts[i].c);
    mcf.add_edge(i + n, 2 * n + 2, INF, 0);

    if(i < n - 1) { // add edge to next chango
      mcf.add_edge(i, i + 1, INF, 0); // we don't take it
    }

    fore(j, i + 1, n) if(ts[i].s + ts[i].t <= ts[j].s) {
      mcf.add_edge(i + n, j, INF, 0); break;
    }
  }
  auto p = mcf.get_flow(2 * n, 2 * n + 2);
  bool res[n]; mset(res, 0);
  fore(i, 0, n) {
    for(auto e : mcf.g[i]) if(e.to == i + n && e.f) res[ts[i].id] = 1;
  }
  fore(i, 0, n) cout << res[i] << " "; cout << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define fst first
#define snd second
#define mset(a, b) memset(a, b, sizeof(a))

typedef long long ll;

typedef ll tf;
typedef ll tc;
const tf INF=1e9;
struct MCF{
	int n;
	vector<tc> prio, pot; vector<tf> curflow; vector<int> prevedge,prevnode;
	priority_queue<pair<tc, int>, vector<pair<tc, int>>, greater<pair<tc, int>>> q;
	struct edge{int to, rev; tf f, cap; tc cost;};
	vector<vector<edge>> g;
	MCF(int n):n(n),prio(n),curflow(n),prevedge(n),prevnode(n),pot(n),g(n){}
	void add_edge(int s, int t, tf cap, tc cost) {
    // cout << s << " " << t << " " << cap << " " << cost << endl;
		g[s].pb((edge){t,SZ(g[t]),0,cap,cost});
		g[t].pb((edge){s,SZ(g[s])-1,0,0,-cost});
	}
	pair<tf,tc> get_flow(int s, int t) {
		tf flow=0; tc flowcost=0;
    // cout << s << " " << t << endl;
		while(1){
			q.push({0, s});
			fill(ALL(prio),INF);
			prio[s]=0; curflow[s]=INF;
			while(!q.empty()) {
				auto cur=q.top();
				tc d=cur.fst;
        int u=cur.snd;
				q.pop();
				if(d!=prio[u]) continue;
				for(int i=0; i<SZ(g[u]); ++i) {
					edge &e=g[u][i];
					int v=e.to;
					if(e.cap<=e.f) continue;
					tc nprio=prio[u]+e.cost+pot[u]-pot[v];
					if(prio[v]>nprio) {
						prio[v]=nprio;
						q.push({nprio, v});
						prevnode[v]=u; prevedge[v]=i;
						curflow[v]=min(curflow[u], e.cap-e.f);
					}
				}
			}
			if(prio[t]==INF) break;
			fore(i,0,n) pot[i]+=prio[i];
			tf df=min(curflow[t], INF-flow);
			flow+=df;
			for(int v=t; v!=s; v=prevnode[v]) {
				edge &e=g[prevnode[v]][prevedge[v]];
				e.f+=df; g[v][e.rev].f-=df;
				flowcost+=df*e.cost;
			}
		}
		return {flow,flowcost};
	}
};

struct task{int s, t,c,id;};

int main() {
  int n, k; cin >> n >> k;
  MCF mcf(2 * n + 3); mcf.add_edge(2 * n, 2 * n + 1, k, 0);
  vector<task> ts;
  fore(i, 0, n) {
    int s, t , c; cin >> s >> t >> c;
    ts.pb({s, t, c, i});
  }
  sort(ts.begin(), ts.end(), [](task a, task b)->bool{
    return a.s <= b.s;
  });
  fore(i, 0, n) {
    mcf.add_edge(2 * n + 1, i, INF, 0);
    mcf.add_edge(i, i + n, 1, -ts[i].c);
    mcf.add_edge(i + n, 2 * n + 2, INF, 0);

    if(i < n - 1) { // add edge to next chango
      mcf.add_edge(i, i + 1, INF, 0); // we don't take it
    }

    fore(j, i + 1, n) if(ts[i].s + ts[i].t <= ts[j].s) {
      mcf.add_edge(i + n, j, INF, 0); break;
    }
  }
  auto p = mcf.get_flow(2 * n, 2 * n + 2);
  bool res[n]; mset(res, 0);
  fore(i, 0, n) {
    for(auto e : mcf.g[i]) if(e.to == i + n && e.f) res[ts[i].id] = 1;
  }
  fore(i, 0, n) cout << res[i] << " "; cout << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define fst first
#define snd second
#define mset(a, b) memset(a, b, sizeof(a))

typedef long long ll;

typedef ll tf;
typedef ll tc;
const tf INF=1e9;
struct MCF{
	int n;
	vector<tc> prio, pot; vector<tf> curflow; vector<int> prevedge,prevnode;
	priority_queue<pair<tc, int>, vector<pair<tc, int>>, greater<pair<tc, int>>> q;
	struct edge{int to, rev; tf f, cap; tc cost;};
	vector<vector<edge>> g;
	MCF(int n):n(n),prio(n),curflow(n),prevedge(n),prevnode(n),pot(n),g(n){}
	void add_edge(int s, int t, tf cap, tc cost) {
    // cout << s << " " << t << " " << cap << " " << cost << endl;
		g[s].pb((edge){t,SZ(g[t]),0,cap,cost});
		g[t].pb((edge){s,SZ(g[s])-1,0,0,-cost});
	}
	pair<tf,tc> get_flow(int s, int t) {
		tf flow=0; tc flowcost=0;
    // cout << s << " " << t << endl;
		while(1){
			q.push({0, s});
			fill(ALL(prio),INF);
			prio[s]=0; curflow[s]=INF;
			while(!q.empty()) {
				auto cur=q.top();
				tc d=cur.fst;
        int u=cur.snd;
				q.pop();
				if(d!=prio[u]) continue;
				for(int i=0; i<SZ(g[u]); ++i) {
					edge &e=g[u][i];
					int v=e.to;
					if(e.cap<=e.f) continue;
					tc nprio=prio[u]+e.cost+pot[u]-pot[v];
					if(prio[v]>nprio) {
						prio[v]=nprio;
						q.push({nprio, v});
						prevnode[v]=u; prevedge[v]=i;
						curflow[v]=min(curflow[u], e.cap-e.f);
					}
				}
			}
			if(prio[t]==INF) break;
			fore(i,0,n) pot[i]+=prio[i];
			tf df=min(curflow[t], INF-flow);
			flow+=df;
			for(int v=t; v!=s; v=prevnode[v]) {
				edge &e=g[prevnode[v]][prevedge[v]];
				e.f+=df; g[v][e.rev].f-=df;
				flowcost+=df*e.cost;
			}
		}
		return {flow,flowcost};
	}
};

struct task{ll s, t,c,id;};

int main() {
  int n, k; cin >> n >> k;
  MCF mcf(2 * n + 3); mcf.add_edge(2 * n, 2 * n + 1, k, 0);
  vector<task> ts;
  fore(i, 0, n) {
    int s, t , c; cin >> s >> t >> c;
    ts.pb({s, t, c, i});
  }
  sort(ts.begin(), ts.end(), [&](const task a, const task b)->bool{
    return a.s <= b.s;
  });
  fore(i, 0, n) {
    mcf.add_edge(2 * n + 1, i, INF, 0);
    mcf.add_edge(i, i + n, 1, -ts[i].c);
    mcf.add_edge(i + n, 2 * n + 2, INF, 0);

    if(i < n - 1) { // add edge to next chango
      mcf.add_edge(i, i + 1, INF, 0); // we don't take it
    }

    fore(j, i + 1, n) if(ts[i].s + ts[i].t <= ts[j].s) {
      mcf.add_edge(i + n, j, INF, 0); break;
    }
  }
  auto p = mcf.get_flow(2 * n, 2 * n + 2);
  bool res[n]; mset(res, 0);
  fore(i, 0, n) {
    for(auto e : mcf.g[i]) if(e.to == i + n && e.f) res[ts[i].id] = 1;
  }
  fore(i, 0, n) cout << res[i] << " "; cout << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define fst first
#define snd second
#define mset(a, b) memset(a, b, sizeof(a))

typedef long long ll;

typedef ll tf;
typedef ll tc;
const tf INF=1e9;
struct MCF{
	int n;
	vector<tc> prio, pot; vector<tf> curflow; vector<int> prevedge,prevnode;
	priority_queue<pair<tc, int>, vector<pair<tc, int>>, greater<pair<tc, int>>> q;
	struct edge{int to, rev; tf f, cap; tc cost;};
	vector<vector<edge>> g;
	MCF(int n):n(n),prio(n),curflow(n),prevedge(n),prevnode(n),pot(n),g(n){}
	void add_edge(int s, int t, tf cap, tc cost) {
    // cout << s << " " << t << " " << cap << " " << cost << endl;
		g[s].pb((edge){t,SZ(g[t]),0,cap,cost});
		g[t].pb((edge){s,SZ(g[s])-1,0,0,-cost});
	}
	pair<tf,tc> get_flow(int s, int t) {
		tf flow=0; tc flowcost=0;
    // cout << s << " " << t << endl;
		while(1){
			q.push({0, s});
			fill(ALL(prio),INF);
			prio[s]=0; curflow[s]=INF;
			while(!q.empty()) {
				auto cur=q.top();
				tc d=cur.fst;
        int u=cur.snd;
				q.pop();
				if(d!=prio[u]) continue;
				for(int i=0; i<SZ(g[u]); ++i) {
					edge &e=g[u][i];
					int v=e.to;
					if(e.cap<=e.f) continue;
					tc nprio=prio[u]+e.cost+pot[u]-pot[v];
					if(prio[v]>nprio) {
						prio[v]=nprio;
						q.push({nprio, v});
						prevnode[v]=u; prevedge[v]=i;
						curflow[v]=min(curflow[u], e.cap-e.f);
					}
				}
			}
			if(prio[t]==INF) break;
			fore(i,0,n) pot[i]+=prio[i];
			tf df=min(curflow[t], INF-flow);
			flow+=df;
			for(int v=t; v!=s; v=prevnode[v]) {
				edge &e=g[prevnode[v]][prevedge[v]];
				e.f+=df; g[v][e.rev].f-=df;
				flowcost+=df*e.cost;
			}
		}
		return {flow,flowcost};
	}
};

struct task{ll s, t,c,id;};

int main() {
  int n, k; cin >> n >> k;
  MCF mcf(2 * n + 3); mcf.add_edge(2 * n, 2 * n + 1, k, 0);
  vector<task> ts;
  fore(i, 0, n) {
    int s, t , c; cin >> s >> t >> c;
    ts.pb({s, t, c, i});
  }
  sort(ts.begin(), ts.end(), [](const task& a, const task& b)->bool{
    return a.s <= b.s;
  });
  fore(i, 0, n) {
    mcf.add_edge(2 * n + 1, i, INF, 0);
    mcf.add_edge(i, i + n, 1, -ts[i].c);
    mcf.add_edge(i + n, 2 * n + 2, INF, 0);

    if(i < n - 1) { // add edge to next chango
      mcf.add_edge(i, i + 1, INF, 0); // we don't take it
    }

    fore(j, i + 1, n) if(ts[i].s + ts[i].t <= ts[j].s) {
      mcf.add_edge(i + n, j, INF, 0); break;
    }
  }
  auto p = mcf.get_flow(2 * n, 2 * n + 2);
  bool res[n]; mset(res, 0);
  fore(i, 0, n) {
    for(auto e : mcf.g[i]) if(e.to == i + n && e.f) res[ts[i].id] = 1;
  }
  fore(i, 0, n) cout << res[i] << " "; cout << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define fst first
#define snd second
#define mset(a, b) memset(a, b, sizeof(a))

typedef long long ll;

typedef ll tf;
typedef ll tc;
const tf INF=1e9;
struct MCF{
	int n;
	vector<tc> prio, pot; vector<tf> curflow; vector<int> prevedge,prevnode;
	priority_queue<pair<tc, int>, vector<pair<tc, int>>, greater<pair<tc, int>>> q;
	struct edge{int to, rev; tf f, cap; tc cost;};
	vector<vector<edge>> g;
	MCF(int n):n(n),prio(n),curflow(n),prevedge(n),prevnode(n),pot(n),g(n){}
	void add_edge(int s, int t, tf cap, tc cost) {
    // cout << s << " " << t << " " << cap << " " << cost << endl;
		g[s].pb((edge){t,SZ(g[t]),0,cap,cost});
		g[t].pb((edge){s,SZ(g[s])-1,0,0,-cost});
	}
	pair<tf,tc> get_flow(int s, int t) {
		tf flow=0; tc flowcost=0;
    // cout << s << " " << t << endl;
		while(1){
			q.push({0, s});
			fill(ALL(prio),INF);
			prio[s]=0; curflow[s]=INF;
			while(!q.empty()) {
				auto cur=q.top();
				tc d=cur.fst;
        int u=cur.snd;
				q.pop();
				if(d!=prio[u]) continue;
				for(int i=0; i<SZ(g[u]); ++i) {
					edge &e=g[u][i];
					int v=e.to;
					if(e.cap<=e.f) continue;
					tc nprio=prio[u]+e.cost+pot[u]-pot[v];
					if(prio[v]>nprio) {
						prio[v]=nprio;
						q.push({nprio, v});
						prevnode[v]=u; prevedge[v]=i;
						curflow[v]=min(curflow[u], e.cap-e.f);
					}
				}
			}
			if(prio[t]==INF) break;
			fore(i,0,n) pot[i]+=prio[i];
			tf df=min(curflow[t], INF-flow);
			flow+=df;
			for(int v=t; v!=s; v=prevnode[v]) {
				edge &e=g[prevnode[v]][prevedge[v]];
				e.f+=df; g[v][e.rev].f-=df;
				flowcost+=df*e.cost;
			}
		}
		return {flow,flowcost};
	}
};

struct task{int s, t,c,id;};

int main() {
  int n, k; cin >> n >> k;
  MCF mcf(2 * n + 3); mcf.add_edge(2 * n, 2 * n + 1, k, 0);
  vector<task> ts;
  fore(i, 0, n) {
    int s, t , c; cin >> s >> t >> c;
    ts.pb({s, t, c, i});
  }
  sort(ts.begin(), ts.end(), [](const task& a, const task& b)->bool{
    return a.s <= b.s;
  });
  fore(i, 0, n) {
    mcf.add_edge(2 * n + 1, i, INF, 0);
    mcf.add_edge(i, i + n, 1, -ts[i].c);
    mcf.add_edge(i + n, 2 * n + 2, INF, 0);

    if(i < n - 1) { // add edge to next chango
      mcf.add_edge(i, i + 1, INF, 0); // we don't take it
    }

    fore(j, i + 1, n) if(ts[i].s + ts[i].t <= ts[j].s) {
      mcf.add_edge(i + n, j, INF, 0); break;
    }
  }
  auto p = mcf.get_flow(2 * n, 2 * n + 2);
  bool res[n]; mset(res, 0);
  fore(i, 0, n) {
    for(auto e : mcf.g[i]) if(e.to == i + n && e.f) res[ts[i].id] = 1;
  }
  fore(i, 0, n) cout << res[i] << " "; cout << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define fst first
#define snd second
#define mset(a, b) memset(a, b, sizeof(a))

typedef long long ll;

typedef ll tf;
typedef ll tc;
const tf INF=1e9;
struct MCF{
	int n;
	vector<tc> prio, pot; vector<tf> curflow; vector<int> prevedge,prevnode;
	priority_queue<pair<tc, int>, vector<pair<tc, int>>, greater<pair<tc, int>>> q;
	struct edge{int to, rev; tf f, cap; tc cost;};
	vector<vector<edge>> g;
	MCF(int n):n(n),prio(n),curflow(n),prevedge(n),prevnode(n),pot(n),g(n){}
	void add_edge(int s, int t, tf cap, tc cost) {
    // cout << s << " " << t << " " << cap << " " << cost << endl;
		g[s].pb((edge){t,SZ(g[t]),0,cap,cost});
		g[t].pb((edge){s,SZ(g[s])-1,0,0,-cost});
	}
	pair<tf,tc> get_flow(int s, int t) {
		tf flow=0; tc flowcost=0;
    // cout << s << " " << t << endl;
		while(1){
			q.push({0, s});
			fill(ALL(prio),INF);
			prio[s]=0; curflow[s]=INF;
			while(!q.empty()) {
				auto cur=q.top();
				tc d=cur.fst;
        int u=cur.snd;
				q.pop();
				if(d!=prio[u]) continue;
				for(int i=0; i<SZ(g[u]); ++i) {
					edge &e=g[u][i];
					int v=e.to;
					if(e.cap<=e.f) continue;
					tc nprio=prio[u]+e.cost+pot[u]-pot[v];
					if(prio[v]>nprio) {
						prio[v]=nprio;
						q.push({nprio, v});
						prevnode[v]=u; prevedge[v]=i;
						curflow[v]=min(curflow[u], e.cap-e.f);
					}
				}
			}
			if(prio[t]==INF) break;
			fore(i,0,n) pot[i]+=prio[i];
			tf df=min(curflow[t], INF-flow);
			flow+=df;
			for(int v=t; v!=s; v=prevnode[v]) {
				edge &e=g[prevnode[v]][prevedge[v]];
				e.f+=df; g[v][e.rev].f-=df;
				flowcost+=df*e.cost;
			}
		}
		return {flow,flowcost};
	}
};

struct task{int s, t,c;};

int main() {
  int n, k; cin >> n >> k;
  MCF mcf(n + 3); mcf.add_edge(n, n + 1, k, 0);
  vector<task> ts;
  fore(i, 0, n) {
    int s, t , c; cin >> s >> t >> c;
    ts.pb({s, t, c});
  }
  fore(i, 0, n) {
    mcf.add_edge(n + 1, i, 1, -ts[i].c);
    fore(j, 0, n) if(i != j) {
      if(ts[i].s + ts[i].t <= ts[j].s) mcf.add_edge(i, j, 1, -ts[j].c);
    }
    mcf.add_edge(i, n + 2, 1, 0);
  }
  mcf.get_flow(n, n + 2);
  bool res[n]; mset(res, 0);
  fore(i, 0, n) {
    for(auto e : mcf.g[i]) if(e.cap == 0 && e.f < 0) res[i] = 1;
  }
  fore(i, 0, n) cout << res[i] << " "; cout << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define fst first
#define snd second
#define mset(a, b) memset(a, b, sizeof(a))

typedef long long ll;

typedef ll tf;
typedef ll tc;
const tf INF=1e9;
struct MCF{
	int n;
	vector<tc> prio, pot; vector<tf> curflow; vector<int> prevedge,prevnode;
	priority_queue<pair<tc, int>, vector<pair<tc, int>>, greater<pair<tc, int>>> q;
	struct edge{int to, rev; tf f, cap; tc cost;};
	vector<vector<edge>> g;
	MCF(int n):n(n),prio(n),curflow(n),prevedge(n),prevnode(n),pot(n),g(n){}
	void add_edge(int s, int t, tf cap, tc cost) {
    // cout << s << " " << t << " " << cap << " " << cost << endl;
		g[s].pb((edge){t,SZ(g[t]),0,cap,cost});
		g[t].pb((edge){s,SZ(g[s])-1,0,0,-cost});
	}
	pair<tf,tc> get_flow(int s, int t) {
		tf flow=0; tc flowcost=0;
    // cout << s << " " << t << endl;
		while(1){
			q.push({0, s});
			fill(ALL(prio),INF);
			prio[s]=0; curflow[s]=INF;
			while(!q.empty()) {
				auto cur=q.top();
				tc d=cur.fst;
        int u=cur.snd;
				q.pop();
				if(d!=prio[u]) continue;
				for(int i=0; i<SZ(g[u]); ++i) {
					edge &e=g[u][i];
					int v=e.to;
					if(e.cap<=e.f) continue;
					tc nprio=prio[u]+e.cost+pot[u]-pot[v];
					if(prio[v]>nprio) {
						prio[v]=nprio;
						q.push({nprio, v});
						prevnode[v]=u; prevedge[v]=i;
						curflow[v]=min(curflow[u], e.cap-e.f);
					}
				}
			}
			if(prio[t]==INF) break;
			fore(i,0,n) pot[i]+=prio[i];
			tf df=min(curflow[t], INF-flow);
			flow+=df;
			for(int v=t; v!=s; v=prevnode[v]) {
				edge &e=g[prevnode[v]][prevedge[v]];
				e.f+=df; g[v][e.rev].f-=df;
				flowcost+=df*e.cost;
			}
		}
		return {flow,flowcost};
	}
};

struct task{ll s, t,c,id;};

int main() {
  int n, k; cin >> n >> k;
  MCF mcf(2 * n + 3); mcf.add_edge(2 * n, 2 * n + 1, k, 0);
  vector<task> ts;
  fore(i, 0, n) {
    int s, t , c; cin >> s >> t >> c;
    ts.pb({s, t, c, i});
  }
  sort(ts.begin(), ts.end(), [&](const task& a, const task& b)->bool{
    return a.s <= b.s;
  });
  fore(i, 0, n) {
    mcf.add_edge(2 * n + 1, i, INF, 0);
    mcf.add_edge(i, i + n, 1, -ts[i].c);
    mcf.add_edge(i + n, 2 * n + 2, INF, 0);

    if(i < n - 1) { // add edge to next chango
      mcf.add_edge(i, i + 1, INF, 0); // we don't take it
    }

    fore(j, i + 1, n) if(ts[i].s + ts[i].t <= ts[j].s) {
      mcf.add_edge(i + n, j, INF, 0); break;
    }
  }
  auto p = mcf.get_flow(2 * n, 2 * n + 2);
  bool res[n]; mset(res, 0);
  fore(i, 0, n) {
    for(auto e : mcf.g[i]) if(e.to == i + n && e.f) res[ts[i].id] = 1;
  }
  fore(i, 0, n) cout << res[i] << " "; cout << endl;
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define fst first
#define snd second
#define mset(a, b) memset(a, b, sizeof(a))

typedef long long ll;

typedef ll tf;
typedef ll tc;
const tf INF=1e9;
struct MCF{
	int n;
	vector<tc> prio, pot; vector<tf> curflow; vector<int> prevedge,prevnode;
	priority_queue<pair<tc, int>, vector<pair<tc, int>>, greater<pair<tc, int>>> q;
	struct edge{int to, rev; tf f, cap; tc cost;};
	vector<vector<edge>> g;
	MCF(int n):n(n),prio(n),curflow(n),prevedge(n),prevnode(n),pot(n),g(n){}
	void add_edge(int s, int t, tf cap, tc cost) {
    // cout << s << " " << t << " " << cap << " " << cost << endl;
		g[s].pb((edge){t,SZ(g[t]),0,cap,cost});
		g[t].pb((edge){s,SZ(g[s])-1,0,0,-cost});
	}
	pair<tf,tc> get_flow(int s, int t) {
		tf flow=0; tc flowcost=0;
    // cout << s << " " << t << endl;
		while(1){
			q.push({0, s});
			fill(ALL(prio),INF);
			prio[s]=0; curflow[s]=INF;
			while(!q.empty()) {
				auto cur=q.top();
				tc d=cur.fst;
        int u=cur.snd;
				q.pop();
				if(d!=prio[u]) continue;
				for(int i=0; i<SZ(g[u]); ++i) {
					edge &e=g[u][i];
					int v=e.to;
					if(e.cap<=e.f) continue;
					tc nprio=prio[u]+e.cost+pot[u]-pot[v];
					if(prio[v]>nprio) {
						prio[v]=nprio;
						q.push({nprio, v});
						prevnode[v]=u; prevedge[v]=i;
						curflow[v]=min(curflow[u], e.cap-e.f);
					}
				}
			}
			if(prio[t]==INF) break;
			fore(i,0,n) pot[i]+=prio[i];
			tf df=min(curflow[t], INF-flow);
			flow+=df;
			for(int v=t; v!=s; v=prevnode[v]) {
				edge &e=g[prevnode[v]][prevedge[v]];
				e.f+=df; g[v][e.rev].f-=df;
				flowcost+=df*e.cost;
			}
		}
		return {flow,flowcost};
	}
};

struct task{int s, t,c,id;};

int main() {
  int n, k; cin >> n >> k;
  MCF mcf(2 * n + 3); mcf.add_edge(2 * n, 2 * n + 1, k, 0);
  vector<task> ts;
  fore(i, 0, n) {
    int s, t , c; cin >> s >> t >> c;
    ts.pb({s, t, c, i});
  }
  sort(ts.begin(), ts.end(), [](task a, task b)->bool{
    return a.s <= b.s;
  });
  fore(i, 0, n) {
    mcf.add_edge(2 * n + 1, i, 1, 0);
    mcf.add_edge(i, i + n, 1, -ts[i].c);
    mcf.add_edge(i + n, 2 * n + 2, 1, 0);

    if(i < n - 1) { // add edge to next chango
      mcf.add_edge(i, i + 1, 1, 0); // we don't take it
    }

    fore(j, 0, n) if(ts[i].s + ts[i].t <= ts[j].s) {
      mcf.add_edge(i + n, j, 1, 0); break;
    }
  }
  auto p = mcf.get_flow(2 * n, 2 * n + 2);
  bool res[n]; mset(res, 0);
  fore(i, 0, n) {
    for(auto e : mcf.g[i]) if(e.to == i + n && e.f) res[ts[i].id] = 1;
  }
  fore(i, 0, n) cout << res[i] << " "; cout << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define mod 1000000007
#define pb emplace_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll>
#define vi vector< ll >
#define vvi vector< vi >
#define vpi vector< pii >
#define vvpi vector< vpi >
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define test(t) ll t;cin>>t;while(t--)
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
#define fr(i,n) for(ll i=0;i<(n);++i)
#define rep(i,a,b) for(ll i=a;i<=b;++i)
#define per(i,a,b) for(ll i=a;i>=b;i--)
#define remin(a,b) (a=min((a),(b)))
#define remax(a,b) (a=max((a),(b)))
#define debarr(a,n) cerr<<#a<<" : ";for(ll i=0;i<n;i++) cerr<<a[i]<<" "; cerr<<endl;
#define debmat(mat,row,col) cerr<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cerr<<mat[i][j]<<" ";cerr<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const unordered_set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}template <class S, class T>ostream& operator <<(ostream& os, const unordered_map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const set<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
typedef int fType;
typedef int cType;
const fType INF = 0x3f3f3f3f;
// check for flow in i ^ 1
struct edge {
    int u, v;fType flow;cType cost;
    edge() {}
    edge(int u, int v, fType f, cType c) : u(u), v(v), flow(f), cost(c) {}
};
struct MinCostMaxFlow {
    int N;vector < vector <int> > G;
    vector <edge> E;int numEdges;
    vector <int> found, dad;
    vector <cType> dist;

    MinCostMaxFlow(int N):
     N(N), G(N), numEdges(0), found(N), dad(N), dist(N)  {}

    void addEdge(int from, int to, fType capacity, cType cost) {
        // pr(from,to,capacity,cost);
        G[from].push_back(numEdges++);
        E.push_back(edge(from, to, capacity, cost));
        G[to].push_back(numEdges++);
        E.push_back(edge(to, from, 0, cType(-1) * cost));
    }
    bool spfa(int s, int t) {
        fill(dad.begin(), dad.end(), -1);
        fill(dist.begin(), dist.end(), INF);
        fill(found.begin(), found.end(), 0);
        queue <int> Q;dist[s] = 0;Q.push(s);found[s] = true;
        while(!Q.empty()) {
            int u = Q.front(); Q.pop();
            if(u == t) continue;
            for (int i = 0; i < (int)G[u].size(); ++i) {
                edge &pres = E[G[u][i]];
                int v = pres.v;
                if(pres.flow <= 0) continue;
                if(dist[u] + pres.cost < dist[v]) {
                    dad[v] = G[u][i];
                    dist[v] = dist[u] + pres.cost;
                    if(!found[v]) Q.push(v), found[v] = true;
                }
            }
            found[u] = false;
        }
        return (dad[t] != -1);
    }
    fType dfs(int t) {
        fType flow = INF;
        for(int i = dad[t]; i != -1; i = dad[E[i].u]) {
            if(E[i].flow < flow) flow = E[i].flow;
        }
        for(int i = dad[t]; i != -1; i = dad[E[i].u]) {
            E[i].flow -= flow;
            E[i ^ 1].flow += flow;
        }
        return flow;
    }
    pair <fType, cType> getMaxFlow(int s, int t) {
        fType totflow = 0;
        cType totcost = 0;
        while(spfa(s,t)) {
            fType amt = dfs(t);
            totflow += amt;
            totcost += dist[t] * (cType)amt;
        }
        return make_pair(totflow, totcost);
    }
};
signed main()
{
	fast;
	ll n,k;
	cin>>n>>k;
	pair < ll , pair < ll , pii > > arr[n+2];
	ll i;
	for(i=1;i<=n;i++)
		cin>>arr[i].fi>>arr[i].sec.fi>>arr[i].sec.sec.fi,arr[i].sec.sec.sec = i;
	sort(arr+1,arr+n+1);
	arr[n+1] = mp(1e10,mp(0,mp(0,0)));
	MinCostMaxFlow df(n+3);
	ll source = 0,sink = n+2;
	df.addEdge(source,1,k,0);
	for(i=1;i<=n;i++)
	{
		df.addEdge(i,i+1,k,0);
		ll j;
		for(j=i+1;j<=n+1;j++)
		{
			if(arr[j].fi>=arr[i].fi+arr[i].sec.fi)
			{
				df.addEdge(i,j,1,-arr[i].sec.sec.fi);
				break;
			}
		}
		df.addEdge(i,sink,k,0);
	}
	df.addEdge(n+1,sink,k,0);
	ll ans[n+1];
	for(i=0;i<=n;i++)
		ans[i] = 0;
	pii lol = df.getMaxFlow(source,sink);
	for(auto x:df.E)
	{
		if(x.cost<0 and x.flow==0)
			ans[arr[x.u].sec.sec.sec] = 1;
	}
	for(i=1;i<=n;i++)
		cout<<ans[i]<<" ";

}


//satyaki3794
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <algorithm>
#include <climits>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <cassert>
#include <bitset>
#include <iomanip>
#define gc getchar_unlocked
#define pc putchar_unlocked
#define PI (3.14159265)
#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define INF (100000005)
#define SIZE (2)
#define TREESIZE (302144)
#define LEFT(n) (2*n)
#define RIGHT(n) (2*n+1)
#define epsilon 1e-8 //add to double before casting to integer

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ll, int> pli;

#define matrix vector< vector<ll> >

matrix matmul(matrix &a, matrix &b){
    int i, j, k, n = a.size();
    matrix ans (n, vector<ll>(n));
    for(i=0;i<n;i++)
        for(j=0;j<n;j++){
            ll temp = 0;
            for(k=0;k<n;k++)    temp = (temp + a[i][k] * b[k][j]) % MOD;
            ans[i][j] = temp;
        }

    return ans;
}

matrix matpwr(matrix &a, ll p){
    int n = a.size();
    matrix ans(n, vector<ll> (n));
    for(int i=0;i<n;i++)    ans[i][i] = 1;

    while(p){
        if(p&1) ans = matmul(ans, a);

        a = matmul(a, a);
        p >>= 1;
    }
    return ans;
}

ll pwr(ll base, ll p, ll mod = MOD){
    ll ans = 1;
    while(p){
        if(p & 1)   ans = (ans * base) % mod;
        base = (base * base) % mod;
        p /= 2;
    }
    return ans;
}

ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}

ll lcm(ll a, ll b){
    return (a*b) / gcd(a, b);
}

ll invMod(ll n, ll mod = MOD){
    return pwr(n, mod-2);
}

const int InfCost=1e9;
struct MinimumCostMaximumFlow {
    typedef int Index; typedef int Flow; typedef int Cost;
    static const Flow InfCapacity = INF;
    struct Edge {
        Index to; Index rev;
        Flow capacity; Cost cost;
    };
    vector<vector<Edge> > g;
    void init(Index n) { g.assign(n, vector<Edge>()); }
    void add(Index i, Index j, Flow capacity = InfCapacity, Cost cost = Cost()) {
// cout<<"added edge "<<i<<" "<<j<<" "<<capacity<<" "<<cost<<"\n";
        Edge e, f; e.to = j, f.to = i; e.capacity = capacity, f.capacity = 0; e.cost = cost, f.cost = -cost;
        g[i].push_back(e); g[j].push_back(f);
        g[i].back().rev = (Index)g[j].size() - 1; g[j].back().rev = (Index)g[i].size() - 1;
    }
    void addB(Index i, Index j, Flow capacity = InfCapacity, Cost cost = Cost()) {
        add(i, j, capacity, cost);
        add(j, i, capacity, cost);
    }
    pair<Cost,Flow> minimumCostMaximumFlow(Index s, Index t, Flow f = InfCapacity, bool bellmanFord = false) {
        int n = g.size();
        vector<Cost> dist(n); vector<Index> prev(n); vector<Index> prevEdge(n);
        pair<Cost,Flow> total = make_pair(0, 0);
        vector<Cost> potential(n);
        while(f > 0) {
            fill(dist.begin(), dist.end(), InfCost);
            if(bellmanFord || total.second == 0) {
                dist[s] = 0;
                for(int k=0;k<n;k++){
                    bool update = false;
                    for(int i=0;i<n;i++)
                        if(dist[i] != InfCost)
                    for(Index ei = 0; ei < (Index)g[i].size(); ei ++) {
                        const Edge &e = g[i][ei];
                        if(e.capacity <= 0) continue;
                        Index j = e.to; Cost d = dist[i] + e.cost;
                        if(dist[j] > d ) {  //èª¤å·®â�¦
                            dist[j] = d; prev[j] = i; prevEdge[j] = ei;
                            update = true;
                        }
                    }
                    if(!update) break;
                }
            }else {
                vector<bool> vis(n);
                priority_queue<pair<Cost,Index> > q;
                q.push(make_pair(-0, s)); dist[s] = 0;
                while(!q.empty()) {
                    Index i = q.top().second; q.pop();
                    if(vis[i]) continue;
                    vis[i] = true;
                    for(Index ei = 0; ei < (Index)g[i].size(); ei ++) {
                        const Edge &e = g[i][ei];
                        if(e.capacity <= 0) continue;
                        Index j = e.to; Cost d = dist[i] + e.cost + potential[i] - potential[j];
                        if(d < dist[i])  d = dist[i];    //èª¤å·®â�¦
                        if(dist[j] > d) {
                            dist[j] = d; prev[j] = i; prevEdge[j] = ei;
                            q.push(make_pair(-d, j));
                        }
                    }
                }
            }
            if(dist[t] == InfCost) break;
            if(!bellmanFord) for(Index i = 0; i < n; i ++) potential[i] += dist[i];
            Flow d = f; Cost distt = 0;
            for(Index v = t; v != s; ) {
                Index u = prev[v]; const Edge &e = g[u][prevEdge[v]];
                d = min(d, e.capacity); distt += e.cost; v = u;
            }
            f -= d; total.first += d * distt; total.second += d;
            for(Index v = t; v != s; v = prev[v]) {
                Edge &e = g[prev[v]][prevEdge[v]];
                e.capacity -= d; g[e.to][e.rev].capacity += d;
            }
        }
        return total;
    }
};

int n, k, s[1002], e[1003], profit[1003], ans[1003];
iii arr[1002];

int main()
{
    ios_base::sync_with_stdio(0);
    // freopen("input.txt", "r", stdin);

    cin>>n>>k;
    for(int i=0;i<n;i++){
        cin>>s[i]>>e[i]>>profit[i];
        e[i] = s[i]+e[i]-1;
        arr[i] = iii (s[i], ii(e[i], i));
    }
    sort(arr, arr+n);

    MinimumCostMaximumFlow mcmf;
    mcmf.init(1+1+n+n+1);
    int src = 0, dest = 2+2*n;

    mcmf.add(0, 1, k, 0);
    for(int i=0;i<n;i++)
        mcmf.add(1, 2+i, 1, 0);
    for(int i=0;i<n;i++)
        mcmf.add(2+i, 2+n+i, 1, -profit[arr[i].ss.ss]);
    for(int i=0;i<n;i++)
        for(int j=i+1;j<n;j++)
            if(arr[j].ff > arr[i].ss.ff)
                mcmf.add(2+n+i, 2+j, 1, 0);
    for(int i=0;i<n;i++)
        mcmf.add(2+n+i, dest, 1, 0);

    ii flow = mcmf.minimumCostMaximumFlow(src, dest);
// cout<<flow.ff<<" "<<flow.ss<<endl;

// for(int i=0;i<n;i++)    cout<<arr[i].ff<<":"<<arr[i].ss.ff<<":"<<arr[i].ss.ss<<"  ";cout<<endl;
// cout<<"edges\n";
// for(int i=0;i<=dest;i++){
//     cout<<i<<" : ";
//     for(int j=0;j<(int)mcmf.g[i].size();j++)  cout<<mcmf.g[i][j].to<<"="<<mcmf.g[i][j].capacity<<"  ";
//     cout<<endl;
// }cout<<endl;

    for(int i=0;i<n;i++)
        for(int j=0;j<(int)mcmf.g[2+i].size();j++){
            int to = mcmf.g[2+i][j].to;
            if(to != 2+n+i) continue;
            if(mcmf.g[2+i][j].capacity != 0)    continue;
            ans[arr[to-2-n].ss.ss] = 1;
        }

    for(int i=0;i<n;i++)    cout<<ans[i]<<" ";
    return 0;
}


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

namespace MCMF {
	const int MAXN = 2200;
	const int MAXM = 22000;

	typedef int F;
	typedef long long C;

	const C C_INF = (C)1e18;
	const F F_INF = 1e9;

	int fst[MAXN], nxt[MAXM], to[MAXM];
	F cap[MAXM];
	C cost[MAXM];

	int V, E;

	inline void init(int n = MAXN) {
		memset(fst, -1, sizeof(int)*n);
		V = E = 0;
	}
	inline int add_node() { V++; return V-1; }
	inline void add_edge(int u, int v, F f, C w) {
		to[E] = v, cap[E] = f, cost[E] = w, nxt[E] = fst[u], fst[u] = E++;
		to[E] = u, cap[E] = 0, cost[E] = -w, nxt[E] = fst[v], fst[v] = E++;
	}

	int prv[MAXN], q[MAXN], chk[MAXN];
	C dis[MAXN], p[MAXN];

	priority_queue< pair<C, int>, vector< pair<C, int> >, greater< pair<C, int> > > Q;

	void SSSP(int S, int n) {
		for (int i = 0; i < n; i++) dis[i] = C_INF;
		memset(prv, -1, sizeof(int)*n);
		memset(chk, 0, sizeof(int)*n);
		dis[S] = 0;
		Q.push(make_pair(0, S));
		while (!Q.empty()) {
			pair<C, int> cur = Q.top(); Q.pop();
			int u = cur.second; C d = cur.first;
			if (chk[u]) continue; chk[u] = 1;
			for (int j = fst[u]; ~j; j = nxt[j]) if (cap[j]) {
				int v = to[j];
				C w = cost[j] + p[u] - p[v];
				if (dis[v] > dis[u] + w) {
					dis[v] = dis[u] + w, prv[v] = j;
					Q.push(make_pair(dis[v], v));
				}
			}
		}
		C delta = p[S];
		for (int i = 0; i < n; i++) if (dis[i] != C_INF) dis[i] += p[i] - delta, p[i] = dis[i];
	}

	inline void relax(int n) {
		C cmin = C_INF;
		for (int u = 0; u < n; u++) if (dis[u] == C_INF) {
			for (int j = fst[u]; ~j; j = nxt[j]) if (cap[j]) {
				int v = to[j];
				if (dis[v] != C_INF) cmin = min(cmin, cost[j] + p[u] - p[v]);
			}
		}
		if (cmin < 0) {
			for (int u = 0; u < n; u++) {
				if (dis[u] == C_INF) p[u] -= cmin;
			}
		}
	}

	C solve(int S, int T, int n = V) {
		C ret = 0;
		F flow = 0;
		memset(p, 0, sizeof(C)*n);
		while (1) {
			SSSP(S, n);
			if (!~prv[T]) break;
			F flw = F_INF;
			for (int u = T; u != S; u = to[prv[u]^1]) flw = min(flw, cap[prv[u]]);
			flow += flw;
			ret += dis[T] * flw;
			for (int u = T; u != S; u = to[prv[u]^1]) cap[prv[u]] -= flw, cap[prv[u]^1] += flw;
			relax(n);
		}
		return ret;
	}
};

const int N = 2200;

int S[N], T[N], C[N], X[N], Xn;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	MCMF::init(N);

	int n, k; cin >> n >> k;
	for (int i = 1; i < 2100; i++) MCMF::add_edge(i, i + 1, k, 0);
	for (int i = 1; i <= n; i++) cin >> S[i] >> T[i] >> C[i], X[Xn++] = S[i], X[Xn++] = S[i] + T[i];
	sort(X, X + Xn), Xn = unique(X, X + Xn) - X;
	for (int i = 1; i <= n; i++) {
		int s = lower_bound(X, X + Xn, S[i]) - X + 1, t = lower_bound(X, X + Xn, S[i] + T[i]) - X + 1;
		MCMF::add_edge(s, t, 1, -C[i]);
	}
	MCMF::solve(1, 2100, 2101);
	for (int i = 1; i <= n; i++) {
		int s = lower_bound(X, X + Xn, S[i]) - X + 1, t = lower_bound(X, X + Xn, S[i] + T[i]) - X + 1;
		int good = 0;
		for (int j = MCMF::fst[s]; ~j; j = MCMF::nxt[j]) if (!MCMF::cap[j] && MCMF::to[j] == t) good = 1;
		cout << good << " \n"[i == n];
	}

	return 0;
}


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

namespace MCMF {
	const int MAXN = 2200;
	const int MAXM = 2200000;

	typedef int F;
	typedef long long C;

	const C C_INF = (C)1e18;
	const F F_INF = 1e9;

	int fst[MAXN], nxt[MAXM], to[MAXM];
	F cap[MAXM];
	C cost[MAXM];

	int V, E;

	inline void init(int n = MAXN) {
		memset(fst, -1, sizeof(int)*n);
		V = E = 0;
	}
	inline int add_node() { V++; return V-1; }
	inline void add_edge(int u, int v, F f, C w) {
		to[E] = v, cap[E] = f, cost[E] = w, nxt[E] = fst[u], fst[u] = E++;
		to[E] = u, cap[E] = 0, cost[E] = -w, nxt[E] = fst[v], fst[v] = E++;
	}

	int prv[MAXN], q[MAXN], chk[MAXN];
	C dis[MAXN], p[MAXN];

	priority_queue< pair<C, int>, vector< pair<C, int> >, greater< pair<C, int> > > Q;

	void SSSP(int S, int n) {
		for (int i = 0; i < n; i++) dis[i] = C_INF;
		memset(prv, -1, sizeof(int)*n);
		memset(chk, 0, sizeof(int)*n);
		dis[S] = 0;
		Q.push(make_pair(0, S));
		while (!Q.empty()) {
			pair<C, int> cur = Q.top(); Q.pop();
			int u = cur.second; C d = cur.first;
			if (chk[u]) continue; chk[u] = 1;
			for (int j = fst[u]; ~j; j = nxt[j]) if (cap[j]) {
				int v = to[j];
				C w = cost[j] + p[u] - p[v];
				if (dis[v] > dis[u] + w) {
					dis[v] = dis[u] + w, prv[v] = j;
					Q.push(make_pair(dis[v], v));
				}
			}
		}
		C delta = p[S];
		for (int i = 0; i < n; i++) if (dis[i] != C_INF) dis[i] += p[i] - delta, p[i] = dis[i];
	}

	inline void relax(int n) {
		C cmin = C_INF;
		for (int u = 0; u < n; u++) if (dis[u] == C_INF) {
			for (int j = fst[u]; ~j; j = nxt[j]) if (cap[j]) {
				int v = to[j];
				if (dis[v] != C_INF) cmin = min(cmin, cost[j] + p[u] - p[v]);
			}
		}
		if (cmin < 0) {
			for (int u = 0; u < n; u++) {
				if (dis[u] == C_INF) p[u] -= cmin;
			}
		}
	}

	pair<F, C> solve(int S, int T, int n = V) {
		C ret = 0;
		F flow = 0;
		memset(p, 0, sizeof(C)*n);
		while (1) {
			SSSP(S, n);
			if (!~prv[T]) break;
			F flw = F_INF;
			for (int u = T; u != S; u = to[prv[u]^1]) flw = min(flw, cap[prv[u]]);
			flow += flw;
			ret += dis[T] * flw;
			for (int u = T; u != S; u = to[prv[u]^1]) cap[prv[u]] -= flw, cap[prv[u]^1] += flw;
			relax(n);
		}
		return make_pair(flow, ret);
	}
};

const int N = 1100;

struct Data {
	int s, t, c;
	Data(int s = 0, int t = 0, int c = 0) : s(s), t(t), c(c) {}
	void in() {
		cin >> s >> t >> c;
	}
} P[N];

int chk[N];

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	int n, k; cin >> n >> k;
	int S = n + n + 1, T = S + 1, PP = T + 1, src = PP + 1, sink = src + 1;

	MCMF::init(sink + 3);
	for (int i = 1; i <= n; i++) P[i].in();
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (P[j].s >= P[i].s + P[i].t) {
		MCMF::add_edge(i, n + j, 1, -P[i].c);
	}
	for (int i = 1; i <= n; i++) MCMF::add_edge(S, n + i, 1, 0);
	for (int i = 1; i <= n; i++) MCMF::add_edge(i, T, 1, -P[i].c);
	for (int i = 1; i <= n; i++) MCMF::add_edge(src, i, 1, 0);
	for (int i = 1; i <= n; i++) MCMF::add_edge(i, n + i, 1, 0);
	MCMF::add_edge(src, S, k, 0);
	for (int i = 1; i <= n; i++) MCMF::add_edge(n + i, sink, 1, 0);
	MCMF::add_edge(T, sink, k, 0);

	auto it = MCMF::solve(src, sink, sink + 3);
	for (int i = 1; i <= n; i++) {
		for (int j = MCMF::fst[i]; ~j; j = MCMF::nxt[j]) if (!MCMF::cap[j] && MCMF::to[j] == n + i) chk[i] = 1;
	}
	for (int i = 1; i <= n; i++) cout << (!chk[i]) << " \n"[i == n];

	return 0;
}


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

#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}

ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}

const int InfCost=1000000;
struct MinimumCostMaximumFlow {
    typedef int Index; typedef int Flow; typedef int Cost;
    static const Flow InfCapacity = 1000;
    struct Edge {
        Index to; Index rev;
        Flow capacity; Cost cost;
    };
    vector<vector<Edge> > g;
    void init(Index n) { g.assign(n, vector<Edge>()); }
    void add_edge(Index i, Index j, Flow capacity = InfCapacity, Cost cost = Cost()) {
      // cout<<i<<" "<<j<<" "<<capacity<<" "<<cost<<"\n";
        Edge e, f; e.to = j, f.to = i; e.capacity = capacity, f.capacity = 0; e.cost = cost, f.cost = -cost;
        g[i].push_back(e); g[j].push_back(f);
        g[i].back().rev = (Index)g[j].size() - 1; g[j].back().rev = (Index)g[i].size() - 1;
    }
    void addB(Index i, Index j, Flow capacity = InfCapacity, Cost cost = Cost()) {
        add_edge(i, j, capacity, cost);
        add_edge(j, i, capacity, cost);
    }
    pair<Cost,Flow> minimumCostMaximumFlow(Index s, Index t, Flow f = InfCapacity, bool bellmanFord = false) {
        int n = g.size();
        vector<Cost> dist(n); vector<Index> prev(n); vector<Index> prevEdge(n);
        pair<Cost,Flow> total = make_pair(0, 0);
        vector<Cost> potential(n);
        while(f > 0) {
            fill(dist.begin(), dist.end(), InfCost);
            if(bellmanFord || total.second == 0) {
                dist[s] = 0;
                for(int k=0;k<n;k++){
                    bool update = false;
                    for(int i=0;i<n;i++)
                        if(dist[i] != InfCost)
                    for(Index ei = 0; ei < (Index)g[i].size(); ei ++) {
                        const Edge &e = g[i][ei];
                        if(e.capacity <= 0) continue;
                        Index j = e.to; Cost d = dist[i] + e.cost;
                        if(dist[j] > d ) {
                            dist[j] = d; prev[j] = i; prevEdge[j] = ei;
                            update = true;
                        }
                    }
                    if(!update) break;
                }
            }else {
                vector<bool> vis(n);
                priority_queue<pair<Cost,Index> > q;
                q.push(make_pair(-0, s)); dist[s] = 0;
                while(!q.empty()) {
                    Index i = q.top().second; q.pop();
                    if(vis[i]) continue;
                    vis[i] = true;
                    for(Index ei = 0; ei < (Index)g[i].size(); ei ++) {
                        const Edge &e = g[i][ei];
                        if(e.capacity <= 0) continue;
                        Index j = e.to; Cost d = dist[i] + e.cost + potential[i] - potential[j];
                        if(d < dist[i])  d = dist[i];
                        if(dist[j] > d) {
                            dist[j] = d; prev[j] = i; prevEdge[j] = ei;
                            q.push(make_pair(-d, j));
                        }
                    }
                }
            }
            if(dist[t] == InfCost) break;
            if(!bellmanFord) for(Index i = 0; i < n; i ++) potential[i] += dist[i];
            Flow d = f; Cost distt = 0;
            for(Index v = t; v != s; ) {
                Index u = prev[v]; const Edge &e = g[u][prevEdge[v]];
                d = min(d, e.capacity); distt += e.cost; v = u;
            }
            f -= d; total.first += d * distt; total.second += d;
            for(Index v = t; v != s; v = prev[v]) {
                Edge &e = g[prev[v]][prevEdge[v]];
                e.capacity -= d; g[e.to][e.rev].capacity += d;
            }
        }
        return total;
    }
};

const int N = 1100;

struct Data {
	int s, t, c;
	Data(int s = 0, int t = 0, int c = 0) : s(s), t(t), c(c) {}
	void in() {
		cin >> s >> t >> c;
	}
} P[N];

int chk[N];

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	int n, k; cin >> n >> k;
	int S = n + n + 1, T = S + 1, PP = T + 1, src = PP + 1, sink = src + 1;
	MinimumCostMaximumFlow MCMF;
	MCMF.init(sink + 3);

	for (int i = 1; i <= n; i++) P[i].in();
	for (int i = 1; i <= n; i++) {
		int Min = 1111111111, id = 0;
		for (int j = 1; j <= n; j++) if (P[j].s >= P[i].s + P[i].t) {
			if (Min > P[j].s) Min = P[j].s, id = j;
		}
		if (id) MCMF.add_edge(i, n + id, 1, -P[i].c);
	}
	for (int i = 1; i <= n; i++) MCMF.add_edge(S, n + i, 1, 0);
	for (int i = 1; i <= n; i++) MCMF.add_edge(i, T, 1, -P[i].c);
	for (int i = 1; i <= n; i++) MCMF.add_edge(src, i, 1, 0);
	for (int i = 1; i <= n; i++) MCMF.add_edge(i, n + i, 1, 0);
	MCMF.add_edge(src, S, k, 0);
	for (int i = 1; i <= n; i++) MCMF.add_edge(n + i, sink, 1, 0);
	MCMF.add_edge(T, sink, k, 0);

	auto it = MCMF.minimumCostMaximumFlow(src, sink, 111111, true);
	for (int i = 1; i <= n; i++) {
		for(auto e : MCMF.g[i]) {
			if(e.capacity == 0 && e.to == n + i) chk[i] = 1;
		}
	}
	for (int i = 1; i <= n; i++) cout << (!chk[i]) << " \n"[i == n];

	return 0;
}


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

namespace MCMF {
	const int MAXN = 2200;
	const int MAXM = 22000;

	typedef int F;
	typedef long long C;

	const C C_INF = (C)1e18;
	const F F_INF = 1e9;

	int fst[MAXN], nxt[MAXM], to[MAXM];
	F cap[MAXM];
	C cost[MAXM];

	int V, E;

	inline void init(int n = MAXN) {
		memset(fst, -1, sizeof(int)*n);
		V = E = 0;
	}
	inline int add_node() { V++; return V-1; }
	inline void add_edge(int u, int v, F f, C w) {
		to[E] = v, cap[E] = f, cost[E] = w, nxt[E] = fst[u], fst[u] = E++;
		to[E] = u, cap[E] = 0, cost[E] = -w, nxt[E] = fst[v], fst[v] = E++;
	}

	int prv[MAXN], q[MAXN], chk[MAXN];
	C dis[MAXN];

	void SSSP(int S, int T, int n) {
		int h = 0, t = 0;
		for (int j = 0; j < n; j++) dis[j] = C_INF;
		memset(prv, -1, sizeof(int)*n);
		dis[S] = 0, q[t++] = S, chk[S] = 1;
		while (h != t) {
			int u = q[h++]; chk[u] = 0;
			if (h == MAXN) h = 0;
			for (int j = fst[u]; ~j; j = nxt[j]) if (cap[j]) {
				int v = to[j];
				if (dis[v] > dis[u] + cost[j]) {
					dis[v] = dis[u] + cost[j], prv[v] = j;
					if (!chk[v]) {
						q[t++] = v;
						chk[v] = 1;
						if (t == MAXN) t = 0;
					}
				}
			}
		}
	}

	C solve(int S, int T, int n = V) {
		C ret = 0;
		while (1) {
			SSSP(S, T, n);
			if (!~prv[T]) break;
			F flw = F_INF;
			for (int u = T; u != S; u = to[prv[u]^1]) flw = min(flw, cap[prv[u]]);
			ret += dis[T] * flw;
			for (int u = T; u != S; u = to[prv[u]^1]) cap[prv[u]] -= flw, cap[prv[u]^1] += flw;
		}
		return ret;
	}
};

const int N = 2200;

int S[N], T[N], C[N], X[N], Xn, chk[N];

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	int n, k; cin >> n >> k;
	MCMF::init(n + n + 10);
	for (int i = 1; i <= n; i++) cin >> S[i] >> T[i] >> C[i], X[Xn++] = S[i], X[Xn++] = S[i] + T[i];
	sort(X, X + Xn), Xn = unique(X, X + Xn) - X;
	int src = Xn + 1, sink = src + 1;
	for (int i = 1; i <= n; i++) {
		int s = lower_bound(X, X + Xn, S[i]) - X + 1, t = lower_bound(X, X + Xn, S[i] + T[i]) - X + 1;
		MCMF::add_edge(s, t, 1, -C[i]);
		chk[i] = MCMF::E - 2;
	}
	for (int i = 1; i < Xn; i++) MCMF::add_edge(i, i + 1, k, 0);
	MCMF::add_edge(src, 1, k, 0), MCMF::add_edge(Xn, sink, k, 0);
	MCMF::solve(src, sink, sink + 3);
	int res = 0;
	for (int i = 1; i <= n; i++) {
		int s = lower_bound(X, X + Xn, S[i]) - X + 1, t = lower_bound(X, X + Xn, S[i] + T[i]) - X + 1;
		cout << (!MCMF::cap[chk[i]]) << " \n"[i == n];
//		if (good) cerr << "++++++++" << s << " " << t << " "<<C[i]<<endl;
	}

	return 0;
}


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

#define MAXN 10010
#define MAXM 2000100
#define INF 0x3f3f3f3f

struct ZKW_flow{
    int S, T, ecnt;
    int head[MAXN];
    int c[MAXM], w[MAXM], to[MAXM], next[MAXM];
    ZKW_flow(){
        memset(head,0,sizeof(head));
        ecnt = 2;
    }

    void add_edge(int u, int v, int _c, int ww){
        c[ecnt] = _c; w[ecnt] = ww; to[ecnt] = v;
        next[ecnt] = head[u]; head[u] = ecnt++;
        c[ecnt] = 0; w[ecnt] = -ww; to[ecnt] = u;
        next[ecnt] = head[v]; head[v] = ecnt++;
    }

    int dis[MAXN];

    void SPFA(){
        for(int i = 1; i <= T; ++i) dis[i] = INF;
        priority_queue<pair<int, int> > Q;
        dis[S] = 0;
        Q.push(make_pair(0, S));
        while(!Q.empty()){
            int u = Q.top().second, d = -Q.top().first;
            Q.pop();
            if(dis[u] != d) continue;
            for(int p = head[u]; p; p = next[p]){
                int &v = to[p];
                if(c[p] && dis[v] > d + w[p]){
                    dis[v] = d + w[p];
                    Q.push(make_pair(-dis[v], v));
                }
            }
        }
        for(int i = 1; i <= T; ++i) dis[i] = dis[T] - dis[i];
    }

    int ans;
    bool use[MAXN];

    int add_flow(int u, int flow){
        if(u == T){
            ans += dis[S] * flow;
            return flow;
        }
        use[u] = true;
        int now = flow;
        for(int p = head[u]; p; p = next[p]){
            int &v = to[p];
            if(c[p] && !use[v] && dis[u] == dis[v] + w[p]){
                int tmp = add_flow(v, min(now, c[p]));
                c[p] -= tmp;
                c[p^1] += tmp;
                now -= tmp;
                if(!now) break;
            }
        }
        return flow - now;
    }

    bool modify_label(){
        int d = INF;
        for(int u = 1; u <= T; ++u) if(use[u])
            for(int p = head[u]; p; p = next[p]){
                int &v = to[p];
                if(c[p] && !use[v]) d = min(d, dis[v] + w[p] - dis[u]);
            }
        if(d == INF) return false;
        for(int i = 1; i <= T; ++i) if(use[i]) dis[i] += d;
        return true;
    }

    int min_cost_flow(){
        SPFA();
        while(true){
            while(true){
                for(int i = 1; i <= T; ++i) use[i] = 0;
                if(!add_flow(S, INF)) break;
            }
            if(!modify_label()) break;
        }
        return ans;
    }
} MCMF;

const int N = 1100;

struct Data {
	int s, t, c;
	Data(int s = 0, int t = 0, int c = 0) : s(s), t(t), c(c) {}
	void in() {
		cin >> s >> t >> c;
	}
} P[N];

int chk[N];

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	int n, k; cin >> n >> k;
	int S = n + n + 1, T = S + 1, PP = T + 1, src = PP + 1, sink = src + 1;
	MCMF.S = src, MCMF.T = sink;

	for (int i = 1; i <= n; i++) P[i].in();
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (P[j].s >= P[i].s + P[i].t) {
		MCMF.add_edge(i, n + j, 1, -P[i].c);
	}
	for (int i = 1; i <= n; i++) MCMF.add_edge(S, n + i, 1, 0);
	for (int i = 1; i <= n; i++) MCMF.add_edge(i, T, 1, -P[i].c);
	for (int i = 1; i <= n; i++) MCMF.add_edge(src, i, 1, 0);
	for (int i = 1; i <= n; i++) MCMF.add_edge(i, n + i, 1, 0);
	MCMF.add_edge(src, S, k, 0);
	for (int i = 1; i <= n; i++) MCMF.add_edge(n + i, sink, 1, 0);
	MCMF.add_edge(T, sink, k, 0);

	auto it = MCMF.min_cost_flow();
	for (int i = 1; i <= n; i++) {
		for (int j = MCMF.head[i]; j; j = MCMF.next[j]) if (!MCMF.c[j] && MCMF.to[j] == n + i) chk[i] = 1;
	}
	for (int i = 1; i <= n; i++) cout << (!chk[i]) << " \n"[i == n];

	return 0;
}


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

#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}

ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}

const int InfCost=1000000;
struct MinimumCostMaximumFlow {
    typedef int Index; typedef int Flow; typedef int Cost;
    static const Flow InfCapacity = 1000;
    struct Edge {
        Index to; Index rev;
        Flow capacity; Cost cost;
    };
    vector<vector<Edge> > g;
    void init(Index n) { g.assign(n, vector<Edge>()); }
    void add_edge(Index i, Index j, Flow capacity = InfCapacity, Cost cost = Cost()) {
      // cout<<i<<" "<<j<<" "<<capacity<<" "<<cost<<"\n";
        Edge e, f; e.to = j, f.to = i; e.capacity = capacity, f.capacity = 0; e.cost = cost, f.cost = -cost;
        g[i].push_back(e); g[j].push_back(f);
        g[i].back().rev = (Index)g[j].size() - 1; g[j].back().rev = (Index)g[i].size() - 1;
    }
    void addB(Index i, Index j, Flow capacity = InfCapacity, Cost cost = Cost()) {
        add_edge(i, j, capacity, cost);
        add_edge(j, i, capacity, cost);
    }
    pair<Cost,Flow> minimumCostMaximumFlow(Index s, Index t, Flow f = InfCapacity, bool bellmanFord = false) {
        int n = g.size();
        vector<Cost> dist(n); vector<Index> prev(n); vector<Index> prevEdge(n);
        pair<Cost,Flow> total = make_pair(0, 0);
        vector<Cost> potential(n);
        while(f > 0) {
            fill(dist.begin(), dist.end(), InfCost);
            if(bellmanFord || total.second == 0) {
                dist[s] = 0;
                for(int k=0;k<n;k++){
                    bool update = false;
                    for(int i=0;i<n;i++)
                        if(dist[i] != InfCost)
                    for(Index ei = 0; ei < (Index)g[i].size(); ei ++) {
                        const Edge &e = g[i][ei];
                        if(e.capacity <= 0) continue;
                        Index j = e.to; Cost d = dist[i] + e.cost;
                        if(dist[j] > d ) {
                            dist[j] = d; prev[j] = i; prevEdge[j] = ei;
                            update = true;
                        }
                    }
                    if(!update) break;
                }
            }else {
                vector<bool> vis(n);
                priority_queue<pair<Cost,Index> > q;
                q.push(make_pair(-0, s)); dist[s] = 0;
                while(!q.empty()) {
                    Index i = q.top().second; q.pop();
                    if(vis[i]) continue;
                    vis[i] = true;
                    for(Index ei = 0; ei < (Index)g[i].size(); ei ++) {
                        const Edge &e = g[i][ei];
                        if(e.capacity <= 0) continue;
                        Index j = e.to; Cost d = dist[i] + e.cost + potential[i] - potential[j];
                        if(d < dist[i])  d = dist[i];
                        if(dist[j] > d) {
                            dist[j] = d; prev[j] = i; prevEdge[j] = ei;
                            q.push(make_pair(-d, j));
                        }
                    }
                }
            }
            if(dist[t] == InfCost) break;
            if(!bellmanFord) for(Index i = 0; i < n; i ++) potential[i] += dist[i];
            Flow d = f; Cost distt = 0;
            for(Index v = t; v != s; ) {
                Index u = prev[v]; const Edge &e = g[u][prevEdge[v]];
                d = min(d, e.capacity); distt += e.cost; v = u;
            }
            f -= d; total.first += d * distt; total.second += d;
            for(Index v = t; v != s; v = prev[v]) {
                Edge &e = g[prev[v]][prevEdge[v]];
                e.capacity -= d; g[e.to][e.rev].capacity += d;
            }
        }
        return total;
    }
};

const int N = 1100;

struct Data {
	int s, t, c, id;
	Data(int s = 0, int t = 0, int c = 0) : s(s), t(t), c(c) {}
	void in() {
		cin >> s >> t >> c;
	}
	bool operator < (const Data &d) const {
		if (s != d.s) return s < d.s;
		return t < d.t;
	}
} P[N];

int chk[N];

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	int n, k; cin >> n >> k;
	int S = n + n + 1, T = S + 1, PP = T + 1, src = PP + 1, sink = src + 1;
	MinimumCostMaximumFlow MCMF;
	MCMF.init(sink + 3);

	for (int i = 1; i <= n; i++) P[i].in(), P[i].id = i;
	sort(P + 1, P + n + 1);
	for (int i = 1; i <= n; i++) {
		int Min = 1111111111;
		for (int j = i + 1; j <= n; j++) if (P[j].s >= P[i].s + P[i].t) {
			if (Min > P[j].s + P[j].t) Min = P[j].s + P[j].t, MCMF.add_edge(i, n + j, 1, -P[i].c);
		}
	}
	for (int i = 1; i <= n; i++) MCMF.add_edge(S, n + i, 1, 0);
	for (int i = 1; i <= n; i++) MCMF.add_edge(i, T, 1, -P[i].c);
	for (int i = 1; i <= n; i++) MCMF.add_edge(src, i, 1, 0);
	for (int i = 1; i <= n; i++) MCMF.add_edge(i, n + i, 1, 0);
	MCMF.add_edge(src, S, k, 0);
	for (int i = 1; i <= n; i++) MCMF.add_edge(n + i, sink, 1, 0);
	MCMF.add_edge(T, sink, k, 0);

	auto it = MCMF.minimumCostMaximumFlow(src, sink, 111111, true);
	for (int i = 1; i <= n; i++) {
		for(auto e : MCMF.g[i]) {
			if(e.capacity == 0 && e.to == n + i) chk[P[i].id] = 1;
		}
	}
	for (int i = 1; i <= n; i++) cout << (!chk[i]) << " \n"[i == n];

	return 0;
}


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

#define ff first
#define ss second
#define pb push_back
#define MOD (1000000007LL)
#define LEFT(n) (2*(n))
#define RIGHT(n) (2*(n)+1)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int, ii> iii;

ll pwr(ll base, ll p, ll mod=MOD){
ll ans = 1;while(p){if(p&1)ans=(ans*base)%mod;base=(base*base)%mod;p/=2;}return ans;
}

ll gcd(ll a, ll b){
    if(b == 0)  return a;
    return gcd(b, a%b);
}

const int InfCost=1000000;
struct MinimumCostMaximumFlow {
    typedef int Index; typedef int Flow; typedef int Cost;
    static const Flow InfCapacity = 1000;
    struct Edge {
        Index to; Index rev;
        Flow capacity; Cost cost;
    };
    vector<vector<Edge> > g;
    void init(Index n) { g.assign(n, vector<Edge>()); }
    void add_edge(Index i, Index j, Flow capacity = InfCapacity, Cost cost = Cost()) {
      // cout<<i<<" "<<j<<" "<<capacity<<" "<<cost<<"\n";
        Edge e, f; e.to = j, f.to = i; e.capacity = capacity, f.capacity = 0; e.cost = cost, f.cost = -cost;
        g[i].push_back(e); g[j].push_back(f);
        g[i].back().rev = (Index)g[j].size() - 1; g[j].back().rev = (Index)g[i].size() - 1;
    }
    void addB(Index i, Index j, Flow capacity = InfCapacity, Cost cost = Cost()) {
        add_edge(i, j, capacity, cost);
        add_edge(j, i, capacity, cost);
    }
    pair<Cost,Flow> minimumCostMaximumFlow(Index s, Index t, Flow f = InfCapacity, bool bellmanFord = false) {
        int n = g.size();
        vector<Cost> dist(n); vector<Index> prev(n); vector<Index> prevEdge(n);
        pair<Cost,Flow> total = make_pair(0, 0);
        vector<Cost> potential(n);
        while(f > 0) {
            fill(dist.begin(), dist.end(), InfCost);
            if(bellmanFord || total.second == 0) {
                dist[s] = 0;
                for(int k=0;k<n;k++){
                    bool update = false;
                    for(int i=0;i<n;i++)
                        if(dist[i] != InfCost)
                    for(Index ei = 0; ei < (Index)g[i].size(); ei ++) {
                        const Edge &e = g[i][ei];
                        if(e.capacity <= 0) continue;
                        Index j = e.to; Cost d = dist[i] + e.cost;
                        if(dist[j] > d ) {
                            dist[j] = d; prev[j] = i; prevEdge[j] = ei;
                            update = true;
                        }
                    }
                    if(!update) break;
                }
            }else {
                vector<bool> vis(n);
                priority_queue<pair<Cost,Index> > q;
                q.push(make_pair(-0, s)); dist[s] = 0;
                while(!q.empty()) {
                    Index i = q.top().second; q.pop();
                    if(vis[i]) continue;
                    vis[i] = true;
                    for(Index ei = 0; ei < (Index)g[i].size(); ei ++) {
                        const Edge &e = g[i][ei];
                        if(e.capacity <= 0) continue;
                        Index j = e.to; Cost d = dist[i] + e.cost + potential[i] - potential[j];
                        if(d < dist[i])  d = dist[i];
                        if(dist[j] > d) {
                            dist[j] = d; prev[j] = i; prevEdge[j] = ei;
                            q.push(make_pair(-d, j));
                        }
                    }
                }
            }
            if(dist[t] == InfCost) break;
            if(!bellmanFord) for(Index i = 0; i < n; i ++) potential[i] += dist[i];
            Flow d = f; Cost distt = 0;
            for(Index v = t; v != s; ) {
                Index u = prev[v]; const Edge &e = g[u][prevEdge[v]];
                d = min(d, e.capacity); distt += e.cost; v = u;
            }
            f -= d; total.first += d * distt; total.second += d;
            for(Index v = t; v != s; v = prev[v]) {
                Edge &e = g[prev[v]][prevEdge[v]];
                e.capacity -= d; g[e.to][e.rev].capacity += d;
            }
        }
        return total;
    }
};

const int N = 1100;

struct Data {
	int s, t, c;
	Data(int s = 0, int t = 0, int c = 0) : s(s), t(t), c(c) {}
	void in() {
		cin >> s >> t >> c;
	}
} P[N];

int chk[N];

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	int n, k; cin >> n >> k;
	int S = n + n + 1, T = S + 1, PP = T + 1, src = PP + 1, sink = src + 1;
	MinimumCostMaximumFlow MCMF;
	MCMF.init(sink + 3);

	for (int i = 1; i <= n; i++) P[i].in();
	for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) if (P[j].s >= P[i].s + P[i].t) {
		MCMF.add_edge(i, n + j, 1, -P[i].c);
	}
	for (int i = 1; i <= n; i++) MCMF.add_edge(S, n + i, 1, 0);
	for (int i = 1; i <= n; i++) MCMF.add_edge(i, T, 1, -P[i].c);
	for (int i = 1; i <= n; i++) MCMF.add_edge(src, i, 1, 0);
	for (int i = 1; i <= n; i++) MCMF.add_edge(i, n + i, 1, 0);
	MCMF.add_edge(src, S, k, 0);
	for (int i = 1; i <= n; i++) MCMF.add_edge(n + i, sink, 1, 0);
	MCMF.add_edge(T, sink, k, 0);

	auto it = MCMF.minimumCostMaximumFlow(src, sink, 111111, true);
	for (int i = 1; i <= n; i++) {
		for(auto e : MCMF.g[i]) {
			if(e.capacity == 0 && e.to == n + i) chk[i] = 1;
		}
	}
	for (int i = 1; i <= n; i++) cout << (!chk[i]) << " \n"[i == n];

	return 0;
}


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

#define MAXN 10010
#define MAXM 100010
#define INF 0x3f3f3f3f

struct ZKW_flow{
    int S, T, ecnt;
    int head[MAXN];
    int c[MAXM], w[MAXM], to[MAXM], next[MAXM];
    ZKW_flow(){
        memset(head,0,sizeof(head));
        ecnt = 2;
    }

    void add_edge(int u, int v, int _c, int ww){
        c[ecnt] = _c; w[ecnt] = ww; to[ecnt] = v;
        next[ecnt] = head[u]; head[u] = ecnt++;
        c[ecnt] = 0; w[ecnt] = -ww; to[ecnt] = u;
        next[ecnt] = head[v]; head[v] = ecnt++;
    }

    int dis[MAXN];

    void SPFA(){
        for(int i = 1; i <= T; ++i) dis[i] = INF;
        priority_queue<pair<int, int> > Q;
        dis[S] = 0;
        Q.push(make_pair(0, S));
        while(!Q.empty()){
            int u = Q.top().second, d = -Q.top().first;
            Q.pop();
            if(dis[u] != d) continue;
            for(int p = head[u]; p; p = next[p]){
                int &v = to[p];
                if(c[p] && dis[v] > d + w[p]){
                    dis[v] = d + w[p];
                    Q.push(make_pair(-dis[v], v));
                }
            }
        }
        for(int i = 1; i <= T; ++i) dis[i] = dis[T] - dis[i];
    }

    int ans, flw;
    bool use[MAXN];

    int add_flow(int u, int flow){
        if(u == T){
            ans += dis[S] * flow;
            flw += flow;
            return flow;
        }
        use[u] = true;
        int now = flow;
        for(int p = head[u]; p; p = next[p]){
            int &v = to[p];
            if(c[p] && !use[v] && dis[u] == dis[v] + w[p]){
                int tmp = add_flow(v, min(now, c[p]));
                c[p] -= tmp;
                c[p^1] += tmp;
                now -= tmp;
                if(!now) break;
            }
        }
        return flow - now;
    }

    bool modify_label(){
        int d = INF;
        for(int u = 1; u <= T; ++u) if(use[u])
            for(int p = head[u]; p; p = next[p]){
                int &v = to[p];
                if(c[p] && !use[v]) d = min(d, dis[v] + w[p] - dis[u]);
            }
        if(d == INF) return false;
        for(int i = 1; i <= T; ++i) if(use[i]) dis[i] += d;
        return true;
    }

    int solve(){
        SPFA();
        while(true){
            while(true){
                for(int i = 1; i <= T; ++i) use[i] = 0;
                if(!add_flow(S, INF)) break;
            }
            if(!modify_label()) break;
        }
        return ans;
    }
} MCMF;

const int N = 2200;

int S[N], T[N], C[N], X[N], Xn;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	int n, k; cin >> n >> k;
	for (int i = 1; i <= n; i++) cin >> S[i] >> T[i] >> C[i], X[Xn++] = S[i], X[Xn++] = S[i] + T[i];
	sort(X, X + Xn), Xn = unique(X, X + Xn) - X;
	MCMF.S = Xn + 1, MCMF.T = MCMF.S + 1;
	for (int i = 1; i <= n; i++) {
		int s = lower_bound(X, X + Xn, S[i]) - X + 1, t = lower_bound(X, X + Xn, S[i] + T[i]) - X + 1;
		MCMF.add_edge(s, t, 1, -C[i]);
	}
	for (int i = 1; i < Xn; i++) MCMF.add_edge(i, i + 1, k, 0);
	MCMF.add_edge(MCMF.S, 1, k, 0), MCMF.add_edge(Xn, MCMF.T, k, 0);
	MCMF.solve();
	for (int i = 1; i <= n; i++) {
		int s = lower_bound(X, X + Xn, S[i]) - X + 1, t = lower_bound(X, X + Xn, S[i] + T[i]) - X + 1;
		int good = 0;
		for (int p = MCMF.head[s]; p; p = MCMF.next[p]) if (!MCMF.c[p] && MCMF.to[p] == t) good = 1;
		cout << good << " \n"[i == n];
	}

	return 0;
}


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

namespace MCMF {
	const int MAXN = 2200;
	const int MAXM = 22000;

	typedef int F;
	typedef long long C;

	const C C_INF = (C)1e18;
	const F F_INF = 1e9;

	int fst[MAXN], nxt[MAXM], to[MAXM];
	F cap[MAXM];
	C cost[MAXM];

	int V, E;

	inline void init(int n = MAXN) {
		memset(fst, -1, sizeof(int)*n);
		V = E = 0;
	}
	inline int add_node() { V++; return V-1; }
	inline void add_edge(int u, int v, F f, C w) {
		to[E] = v, cap[E] = f, cost[E] = w, nxt[E] = fst[u], fst[u] = E++;
		to[E] = u, cap[E] = 0, cost[E] = -w, nxt[E] = fst[v], fst[v] = E++;
	}

	int prv[MAXN], q[MAXN], chk[MAXN];
	C dis[MAXN];

	void SSSP(int S, int T, int n) {
		int h = 0, t = 0;
		for (int j = 0; j < n; j++) dis[j] = C_INF;
		memset(prv, -1, sizeof(int)*n);
		dis[S] = 0, q[t++] = S, chk[S] = 1;
		while (h != t) {
			int u = q[h++]; chk[u] = 0;
			if (h == MAXN) h = 0;
			for (int j = fst[u]; ~j; j = nxt[j]) if (cap[j]) {
				int v = to[j];
				if (dis[v] > dis[u] + cost[j]) {
					dis[v] = dis[u] + cost[j], prv[v] = j;
					if (!chk[v]) {
						q[t++] = v;
						chk[v] = 1;
						if (t == MAXN) t = 0;
					}
				}
			}
		}
	}

	C solve(int S, int T, int n = V) {
		C ret = 0;
		while (1) {
			SSSP(S, T, n);
			if (!~prv[T]) break;
			F flw = F_INF;
			for (int u = T; u != S; u = to[prv[u]^1]) flw = min(flw, cap[prv[u]]);
			ret += dis[T] * flw;
			for (int u = T; u != S; u = to[prv[u]^1]) cap[prv[u]] -= flw, cap[prv[u]^1] += flw;
		}
		return ret;
	}
};

const int N = 2200;

int S[N], T[N], C[N], X[N], Xn;

int main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

	int n, k; cin >> n >> k;
	MCMF::init(n + n + 10);
	for (int i = 1; i <= n; i++) cin >> S[i] >> T[i] >> C[i], X[Xn++] = S[i], X[Xn++] = S[i] + T[i];
	sort(X, X + Xn), Xn = unique(X, X + Xn) - X;
	int src = Xn + 1, sink = src + 1;
	for (int i = 1; i <= n; i++) {
		int s = lower_bound(X, X + Xn, S[i]) - X + 1, t = lower_bound(X, X + Xn, S[i] + T[i]) - X + 1;
		MCMF::add_edge(s, t, 1, -C[i]);
		assert(1 <= s && s <= Xn && 1 <= t && t <= Xn);
	}
	for (int i = 1; i < Xn; i++) MCMF::add_edge(i, i + 1, k, 0);
	MCMF::add_edge(src, 1, k, 0), MCMF::add_edge(Xn, sink, k, 0);
	MCMF::solve(src, sink, sink + 3);
	for (int i = 1; i <= n; i++) {
		int s = lower_bound(X, X + Xn, S[i]) - X + 1, t = lower_bound(X, X + Xn, S[i] + T[i]) - X + 1;
		int good = 0;
		for (int j = MCMF::fst[s]; ~j; j = MCMF::nxt[j]) if (!MCMF::cap[j] && MCMF::to[j] == t) good = 1;
		cout << good << " \n"[i == n];
	}

	return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct Task{
	int s, t, c, tt;
};
struct Edge{
	int to, cap, cost, next;
};
Edge E[4250];
int head[1050], ne = 1;
Task tasks[1001];
map<int, int> M;
int NV, S, T;
inline void addEdge(int from, int to, int cap, int cost) {
	E[++ne].to = to, E[ne].next = head[from], head[from] = ne;
	E[ne].cap = cap, E[ne].cost = cost;
	E[++ne].to = from, E[ne].next = head[to], head[to] = ne;
	E[ne].cap = 0, E[ne].cost = -cost;
}
int d[1050], p[1050];
bool inqueue[1050];
void mcmf() {
	//int f = 0, c = 0;
	while(1) {
		for(int i = 0; i < NV; ++i) d[i] = 1e9;
		queue<int> Q;
		Q.push(S); d[S] = 0;
		while(!Q.empty()) {
			auto v = Q.front(); Q.pop();
			inqueue[v] = 0;
			for(int x = head[v]; x; x = E[x].next) {
				int &u = E[x].to, &cap = E[x].cap, &cost = E[x].cost;
				if(cap > 0 and d[v] + cost < d[u]) {
					d[u] = d[v] + cost;
					p[u] = x; // parent edge
					if(!inqueue[u]) Q.push(u), inqueue[u] = 1;
				}
			}
		}
		if(d[T] == 1e9) break;
		int df = 1e9;
		for(int i = T; i != S; i = E[p[i] ^ 1].to)
			df = min(df, E[p[i]].cap);
		for(int i = T; i != S; i = E[p[i] ^ 1].to)
			E[p[i]].cap -= df, E[p[i] ^ 1].cap += df;
		//f += df, c += df * d[T];
	}
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; ++i) {
		cin >> tasks[i].s >> tasks[i].t >> tasks[i].c;
		M[tasks[i].s] = -1;
	}
	int id = 0;
	for(auto &x : M)
		x.second = ++id;
	NV = M.size() + 2;
	S = 0, T = NV - 1;
	for(int i = 1; i < NV; ++i)
		addEdge(i-1, i, k, 0);
	vector<int> ans;
	for(int i = 0; i < n; ++i) {
		int from = M.lower_bound(tasks[i].s)->second;
		auto it = M.lower_bound(tasks[i].s + tasks[i].t);
		int to = it == M.end() ? T : it->second;
		addEdge(from, to, 1, -tasks[i].c);
		ans.push_back(ne-1);
	}
	mcmf();
	for(auto x : ans)
		cout << (E[x].cap == 0 ? 1 : 0) << ' ';
    return 0;
}


#include <bits/stdc++.h>
using namespace std;
struct Task{
	int s, t, c, tt;
};
struct Edge{
	int to, cap, cost, next;
};
Edge E[2050];
int head[1050], ne = 1;
Task tasks[1001];
map<int, int> M;
int NV, S, T;
inline void addEdge(int from, int to, int cap, int cost) {
	E[++ne].to = to, E[ne].next = head[from], head[from] = ne;
	E[ne].cap = cap, E[ne].cost = cost;
	E[++ne].to = from, E[ne].next = head[to], head[to] = ne;
	E[ne].cap = 0, E[ne].cost = -cost;
}
int d[1050], p[1050];
bool inqueue[1050];
void mcmf() {
	//int f = 0, c = 0;
	while(1) {
		for(int i = 0; i < NV; ++i) d[i] = 1e9;
		queue<int> Q;
		Q.push(S); d[S] = 0;
		while(!Q.empty()) {
			auto v = Q.front(); Q.pop();
			inqueue[v] = 0;
			for(int x = head[v]; x; x = E[x].next) {
				int &u = E[x].to, &cap = E[x].cap, &cost = E[x].cost;
				if(cap > 0 and d[v] + cost < d[u]) {
					d[u] = d[v] + cost;
					p[u] = x; // parent edge
					if(!inqueue[u]) Q.push(u), inqueue[u] = 1;
				}
			}
		}
		if(d[T] == 1e9) break;
		int df = 1e9;
		for(int i = T; i != S; i = E[p[i] ^ 1].to)
			df = min(df, E[p[i]].cap);
		for(int i = T; i != S; i = E[p[i] ^ 1].to)
			E[p[i]].cap -= df, E[p[i] ^ 1].cap += df;
		//f += df, c += df * d[T];
	}
}
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; ++i) {
		cin >> tasks[i].s >> tasks[i].t >> tasks[i].c;
		M[tasks[i].s] = -1;
	}
	int id = 0;
	for(auto &x : M)
		x.second = ++id;
	NV = M.size() + 2;
	S = 0, T = NV - 1;
	for(int i = 1; i < NV; ++i)
		addEdge(i-1, i, k, 0);
	vector<int> ans;
	for(int i = 0; i < n; ++i) {
		int from = M.lower_bound(tasks[i].s)->second;
		auto it = M.lower_bound(tasks[i].s + tasks[i].t);
		int to = it == M.end() ? T : it->second;
		addEdge(from, to, 1, -tasks[i].c);
		ans.push_back(ne-1);
	}
	mcmf();
	for(auto x : ans)
		cout << (E[x].cap == 0 ? 1 : 0) << ' ';
    return 0;
}


#include <bits/stdc++.h>
#define N 5001
using namespace std;
struct edge { int u,k; };
vector <edge> e[N];
edge tre[N];
vector <int> a[N],cv[N];
int u,v,n,m,i,d[N],inq[N],L[N],R[N],cnt,f[2*N][2],c[2*N][2],w[2*N][2],k,tr[N],cc[N],kq[N];
void add(int u,int v,int C,int W,int CV)
{
    a[u].push_back(v); a[v].push_back(u);
    m++;
    e[u].push_back({ m,0 }); e[v].push_back({ m,1 });
    cv[u].push_back(CV); cv[v].push_back(CV);
    c[m][0]=C; w[m][0]=w[m][1]=W;
}
void nenso()
{
    vector <int> vec;
    map <int,int> rr;
    for(i=1;i<=n;i++) { vec.push_back(L[i]); vec.push_back(R[i]); }
    sort(vec.begin(),vec.end());
    int cnt=1;
    for(i=0;i<vec.size();i++)
    {
        rr[vec[i]]=cnt;
        if(i+1<vec.size() && vec[i]<vec[i+1]) cnt++;
    }
    for(i=1;i<=n;i++) { L[i]=rr[L[i]]; R[i]=rr[R[i]]; }
}
bool BFS()
{
    for(u=0;u<=2*n+1;u++) { d[u]=-1; inq[u]=0; }
    queue <int> q;
    d[0]=0; q.push(0); inq[0]=1;
    while(q.size()>0)
    {
        int u=q.front(); q.pop(); inq[u]=0;
        for(i=0;i<a[u].size();i++)
        {
            edge tg=e[u][i];
            if(f[tg.u][tg.k]<c[tg.u][tg.k])
            {
                int v=a[u][i];
                if(f[tg.u][tg.k]>=0) k=w[tg.u][tg.k]; else k=-w[tg.u][tg.k];
               // cerr<<w[tg.u][tg.k];
                if(d[v]<d[u]+k)
                {
                    d[v]=d[u]+k; tr[v]=u; tre[v]=tg;
                    if(inq[v]==0) { q.push(v); inq[v]=1; }
                }
            }
        }
    }
    return d[2*n+1]>-1;
}
void incflow()
{
    u=2*n+1;
    while(u>0)
    {
        v=tr[u]; edge tg=tre[u];
        f[tg.u][tg.k]++; f[tg.u][1-tg.k]--;
        u=v;
    }
}
int main()
{
   // freopen("ntu.inp","r",stdin);
    //freopen("ntu.out","w",stdout);
    cin>>n>>k;
    for(i=0;i<=2*n;i++) add(i,i+1,k,0,0);
    for(i=1;i<=n;i++) { cin>>L[i]>>R[i]>>cc[i]; R[i]=L[i]+R[i]-1; }
    nenso();
    for(i=1;i<=n;i++) add(L[i],R[i]+1,1,cc[i],i);
    while(BFS()) incflow();
    for(u=0;u<=2*n+1;u++)
        for(i=0;i<a[u].size();i++)
            if(f[e[u][i].u][e[u][i].k]==1) kq[cv[u][i]]=1;
    for(i=1;i<=n;i++) cout<<kq[i]<<" ";
}


#include <algorithm>
#include <cassert>
#include <iostream>
#include <limits>
#include <queue>
#include <vector>
using namespace std;

// Warning: when choosing flow_t and cost_t, make sure they can handle the sum of flows and costs, not just individual
// flows and costs.
template<typename flow_t, typename cost_t>
struct min_cost_flow {
    const cost_t COST_INF = numeric_limits<cost_t>::max() / 2;

    struct edge {
        int node, rev;
        flow_t capacity;
        cost_t cost;

        edge() {}

        edge(int _node, int _rev, flow_t _capacity, cost_t _cost)
            : node(_node), rev(_rev), capacity(_capacity), cost(_cost) {}
    };

    int V = -1, E = 0;
    vector<vector<edge>> adj;
    vector<cost_t> dist;
    vector<int> prev;
    vector<edge*> prev_edge;
    bool too_many_bellman_ford_iterations = false;

    min_cost_flow(int vertices = -1) {
        if (vertices >= 0)
            init(vertices);
    }

    void init(int vertices) {
        V = vertices;
        E = 0;
        adj.assign(V, {});
        dist.resize(V);
        prev.resize(V);
        prev_edge.resize(V);
        too_many_bellman_ford_iterations = false;
    }

    void add_directional_edge(int u, int v, flow_t capacity, cost_t cost) {
        assert(0 <= u && u < V && 0 <= v && v < V);
        edge uv_edge(v, adj[v].size() + (u == v ? 1 : 0), capacity, cost);
        edge vu_edge(u, adj[u].size(), 0, -cost);
        adj[u].push_back(uv_edge);
        adj[v].push_back(vu_edge);
        E++;
    }

    edge &reverse_edge(const edge &e) {
        return adj[e.node][e.rev];
    }

    bool bellman_ford(int source, int sink) {
        for (int i = 0; i < V; i++) {
            dist[i] = COST_INF;
            prev[i] = -1;
            prev_edge[i] = nullptr;
        }

        long long work = 0;
        vector<int> last_seen(V, -1);
        vector<int> nodes = {source}, next_nodes;
        dist[source] = 0;

        for (int iteration = 0; iteration < V; iteration++) {
            next_nodes.clear();

            for (int node : nodes) {
                for (edge &e : adj[node])
                    if (e.capacity > 0 && dist[node] + e.cost < dist[e.node]) {
                        dist[e.node] = dist[node] + e.cost;
                        prev[e.node] = node;
                        prev_edge[e.node] = &e;

                        if (last_seen[e.node] != iteration) {
                            last_seen[e.node] = iteration;
                            next_nodes.push_back(e.node);
                        }
                    }

                work += adj[node].size();
            }

            swap(nodes, next_nodes);
        }

        if (work > 1.75 * E * (32 - __builtin_clz(V)) + 100)
            too_many_bellman_ford_iterations = true;

        return prev[sink] != -1;
    }

    struct dijkstra_state {
        cost_t dist;
        int node;

        dijkstra_state() {}

        dijkstra_state(cost_t _dist, int _node) : dist(_dist), node(_node) {}

        bool operator<(const dijkstra_state &other) const {
            return dist > other.dist;
        }
    };

    void dijkstra_check(int node, cost_t potential_dist, int previous, edge *previous_edge,
                        priority_queue<dijkstra_state> &pq) {
        if (potential_dist < dist[node]) {
            dist[node] = potential_dist;
            prev[node] = previous;
            prev_edge[node] = previous_edge;
            pq.emplace(dist[node], node);
        }
    }

    bool dijkstra(int source, int sink) {
        dist.assign(V, COST_INF);
        prev.assign(V, -1);
        prev_edge.assign(V, nullptr);

        priority_queue<dijkstra_state> pq;
        dijkstra_check(source, 0, -1, nullptr, pq);

        while (!pq.empty()) {
            dijkstra_state top = pq.top();
            pq.pop();

            if (top.dist > dist[top.node])
                continue;

            for (edge &e : adj[top.node])
                if (e.capacity > 0)
                    dijkstra_check(e.node, top.dist + e.cost, top.node, &e, pq);
        }

        return prev[sink] != -1;
    }

    void reduce_cost() {
        for (int i = 0; i < V; i++)
            for (edge &e : adj[i])
                if (dist[i] < COST_INF && dist[e.node] < COST_INF)
                    e.cost += dist[i] - dist[e.node];
    }

    pair<flow_t, cost_t> solve_min_cost_flow(int source, int sink, flow_t flow_goal = numeric_limits<flow_t>::max()) {
        assert(V >= 0);
        flow_t total_flow = 0;
        cost_t total_cost = 0;

        while (total_flow < flow_goal && bellman_ford(source, sink)) {
            if (too_many_bellman_ford_iterations)
                break;

            flow_t path_cap = flow_goal - total_flow;
            cost_t cost_sum = 0;

            for (int node = sink; prev[node] != -1; node = prev[node])
                path_cap = min(path_cap, prev_edge[node]->capacity);

            for (int node = sink; prev[node] != -1; node = prev[node]) {
                edge *e = prev_edge[node];
                e->capacity -= path_cap;
                reverse_edge(*e).capacity += path_cap;
                cost_sum += e->cost;
            }

            total_flow += path_cap;
            total_cost += cost_sum * path_cap;
        }

        if (too_many_bellman_ford_iterations) {
            cost_t reduce_sum = 0;

            do {
                reduce_cost();
                reduce_sum += dist[sink];
                flow_t path_cap = flow_goal - total_flow;

                for (int node = sink; prev[node] != -1; node = prev[node])
                    path_cap = min(path_cap, prev_edge[node]->capacity);

                for (int node = sink; prev[node] != -1; node = prev[node]) {
                    edge *e = prev_edge[node];
                    assert(e->cost == 0);
                    e->capacity -= path_cap;
                    reverse_edge(*e).capacity += path_cap;
                }

                total_flow += path_cap;
                total_cost += reduce_sum * path_cap;
            } while (total_flow < flow_goal && dijkstra(source, sink));
        }

        return make_pair(total_flow, total_cost);
    }
};

struct task {
    int start, end, profit, index;

    bool operator<(const task &other) const {
        return start < other.start;
    }
};

int N, K;
vector<task> tasks;

int find_next_task(int end) {
    int low = 0, high = N;

    while (low < high) {
        int mid = (low + high) / 2;

        if (end <= tasks[mid].start)
            high = mid;
        else
            low = mid + 1;
    }

    return low;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    cin >> N >> K;
    tasks.resize(N);

    for (int i = 0; i < N; i++) {
        int time;
        cin >> tasks[i].start >> time >> tasks[i].profit;
        tasks[i].end = tasks[i].start + time;
        tasks[i].index = i;
    }

    sort(tasks.begin(), tasks.end());
    int V = 3 * N + 2;
    int source = V - 2, sink = V - 1;
    min_cost_flow<int, int> graph(V);

    // Create the timeline.
    graph.add_directional_edge(source, 2 * N, K, 0);

    for (int i = 0; i + 1 < N; i++)
        graph.add_directional_edge(2 * N + i, 2 * N + i + 1, K, 0);

    graph.add_directional_edge(2 * N + (N - 1), sink, K, 0);

    // Create the edges for each task.
    for (int i = 0; i < N; i++) {
        int in = 2 * i, out = 2 * i + 1;

        graph.add_directional_edge(2 * N + i, in, 1, 0);
        graph.add_directional_edge(in, out, 1, -tasks[i].profit);

        int next_task = find_next_task(tasks[i].end);
        graph.add_directional_edge(out, next_task < N ? 2 * N + find_next_task(tasks[i].end) : sink, 1, 0);
    }

    cerr << -graph.solve_min_cost_flow(source, sink).second << endl;
    vector<bool> answer(N, false);

    // For each task, it's solved iff its edge was used.
    for (int i = 0; i < N; i++)
        for (min_cost_flow<int, int>::edge &e : graph.adj[2 * i])
            if (e.node == 2 * i + 1)
                answer[tasks[i].index] = e.capacity == 0;

    for (int i = 0; i < N; i++)
        cout << (int) answer[i] << (i < N - 1 ? ' ' : '\n');
}


#include <algorithm>
#include <cassert>
#include <iostream>
#include <limits>
#include <queue>
#include <vector>
using namespace std;

// Warning: when choosing flow_t and cost_t, make sure they can handle the sum of flows and costs, not just individual
// flows and costs.
template<typename flow_t, typename cost_t>
struct min_cost_flow {
    const cost_t COST_INF = numeric_limits<cost_t>::max() / 2;

    struct edge {
        int node, rev;
        flow_t capacity;
        cost_t cost;

        edge() {}

        edge(int _node, int _rev, flow_t _capacity, cost_t _cost)
            : node(_node), rev(_rev), capacity(_capacity), cost(_cost) {}
    };

    int V = -1, E = 0;
    vector<vector<edge>> adj;
    vector<cost_t> dist;
    vector<int> prev;
    vector<edge*> prev_edge;
    bool too_many_bellman_ford_iterations = false;

    min_cost_flow(int vertices = -1) {
        if (vertices >= 0)
            init(vertices);
    }

    void init(int vertices) {
        V = vertices;
        E = 0;
        adj.assign(V, {});
        dist.resize(V);
        prev.resize(V);
        prev_edge.resize(V);
        too_many_bellman_ford_iterations = false;
    }

    void add_directional_edge(int u, int v, flow_t capacity, cost_t cost) {
        assert(0 <= u && u < V && 0 <= v && v < V);
        edge uv_edge(v, adj[v].size() + (u == v ? 1 : 0), capacity, cost);
        edge vu_edge(u, adj[u].size(), 0, -cost);
        adj[u].push_back(uv_edge);
        adj[v].push_back(vu_edge);
        E++;
    }

    edge &reverse_edge(const edge &e) {
        return adj[e.node][e.rev];
    }

    bool bellman_ford(int source, int sink) {
        for (int i = 0; i < V; i++) {
            dist[i] = COST_INF;
            prev[i] = -1;
            prev_edge[i] = nullptr;
        }

        long long work = 0;
        vector<int> last_seen(V, -1);
        vector<int> nodes = {source}, next_nodes;
        dist[source] = 0;

        for (int iteration = 0; iteration < V; iteration++) {
            next_nodes.clear();

            for (int node : nodes) {
                for (edge &e : adj[node])
                    if (e.capacity > 0 && dist[node] + e.cost < dist[e.node]) {
                        dist[e.node] = dist[node] + e.cost;
                        prev[e.node] = node;
                        prev_edge[e.node] = &e;

                        if (last_seen[e.node] != iteration) {
                            last_seen[e.node] = iteration;
                            next_nodes.push_back(e.node);
                        }
                    }

                work += adj[node].size();
            }

            swap(nodes, next_nodes);
        }

        if (work > 1.75 * E * (32 - __builtin_clz(V)) + 100)
            too_many_bellman_ford_iterations = true;

        return prev[sink] != -1;
    }

    struct dijkstra_state {
        cost_t dist;
        int node;

        dijkstra_state() {}

        dijkstra_state(cost_t _dist, int _node) : dist(_dist), node(_node) {}

        bool operator<(const dijkstra_state &other) const {
            return dist > other.dist;
        }
    };

    void dijkstra_check(int node, cost_t potential_dist, int previous, edge *previous_edge,
                        priority_queue<dijkstra_state> &pq) {
        if (potential_dist < dist[node]) {
            dist[node] = potential_dist;
            prev[node] = previous;
            prev_edge[node] = previous_edge;
            pq.emplace(dist[node], node);
        }
    }

    bool dijkstra(int source, int sink) {
        dist.assign(V, COST_INF);
        prev.assign(V, -1);
        prev_edge.assign(V, nullptr);

        priority_queue<dijkstra_state> pq;
        dijkstra_check(source, 0, -1, nullptr, pq);

        while (!pq.empty()) {
            dijkstra_state top = pq.top();
            pq.pop();

            if (top.dist > dist[top.node])
                continue;

            for (edge &e : adj[top.node])
                if (e.capacity > 0)
                    dijkstra_check(e.node, top.dist + e.cost, top.node, &e, pq);
        }

        return prev[sink] != -1;
    }

    void reduce_cost() {
        for (int i = 0; i < V; i++)
            for (edge &e : adj[i])
                if (dist[i] < COST_INF && dist[e.node] < COST_INF)
                    e.cost += dist[i] - dist[e.node];
    }

    pair<flow_t, cost_t> solve_min_cost_flow(int source, int sink, flow_t flow_goal = numeric_limits<flow_t>::max()) {
        assert(V >= 0);
        flow_t total_flow = 0;
        cost_t total_cost = 0;

        while (total_flow < flow_goal && bellman_ford(source, sink)) {
            if (too_many_bellman_ford_iterations)
                break;

            flow_t path_cap = flow_goal - total_flow;
            cost_t cost_sum = 0;

            for (int node = sink; prev[node] != -1; node = prev[node])
                path_cap = min(path_cap, prev_edge[node]->capacity);

            for (int node = sink; prev[node] != -1; node = prev[node]) {
                edge *e = prev_edge[node];
                e->capacity -= path_cap;
                reverse_edge(*e).capacity += path_cap;
                cost_sum += e->cost;
            }

            total_flow += path_cap;
            total_cost += cost_sum * path_cap;
        }

        if (too_many_bellman_ford_iterations) {
            cost_t reduce_sum = 0;

            do {
                reduce_cost();
                reduce_sum += dist[sink];
                flow_t path_cap = flow_goal - total_flow;

                for (int node = sink; prev[node] != -1; node = prev[node])
                    path_cap = min(path_cap, prev_edge[node]->capacity);

                for (int node = sink; prev[node] != -1; node = prev[node]) {
                    edge *e = prev_edge[node];
                    assert(e->cost == 0);
                    e->capacity -= path_cap;
                    reverse_edge(*e).capacity += path_cap;
                }

                total_flow += path_cap;
                total_cost += reduce_sum * path_cap;
            } while (total_flow < flow_goal && dijkstra(source, sink));
        }

        return make_pair(total_flow, total_cost);
    }
};

struct task {
    int start, end, profit, index;

    bool operator<(const task &other) const {
        return start < other.start;
    }
};

int N, K;
vector<task> tasks;

int find_next_task(int end) {
    int low = 0, high = N;

    while (low < high) {
        int mid = (low + high) / 2;

        if (end <= tasks[mid].start)
            high = mid;
        else
            low = mid + 1;
    }

    return low;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> N >> K;
    tasks.resize(N);

    for (int i = 0; i < N; i++) {
        int time;
        cin >> tasks[i].start >> time >> tasks[i].profit;
        tasks[i].end = tasks[i].start + time;
        tasks[i].index = i;
    }

    sort(tasks.begin(), tasks.end());
    int V = 3 * N + 2;
    int source = V - 2, sink = V - 1;
    min_cost_flow<int, int> graph(V);

    // Create the timeline.
    graph.add_directional_edge(source, 2 * N, K, 0);

    for (int i = 0; i + 1 < N; i++)
        graph.add_directional_edge(2 * N + i, 2 * N + i + 1, K, 0);

    graph.add_directional_edge(2 * N + (N - 1), sink, K, 0);

    // Create the edges for each task.
    for (int i = 0; i < N; i++) {
        int in = 2 * i, out = 2 * i + 1;

        graph.add_directional_edge(2 * N + i, in, 1, 0);
        graph.add_directional_edge(in, out, 1, -tasks[i].profit);

        int next_task = find_next_task(tasks[i].end);
        graph.add_directional_edge(out, next_task < N ? 2 * N + find_next_task(tasks[i].end) : sink, 1, 0);
    }

    cerr << -graph.solve_min_cost_flow(source, sink).second << endl;
    vector<int> answer(N, 0);

    // For each task, it's solved iff its edge was used.
    for (int i = 0; i < N; i++)
        for (min_cost_flow<int, int>::edge &e : graph.adj[2 * i])
            if (e.node == 2 * i + 1)
                answer[tasks[i].index] = e.capacity == 0;

    for (int i = 0; i < N; i++)
        cout << (int) answer[i] << (i < N - 1 ? ' ' : '\n');
}


#include <set>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <bitset>
#include <algorithm>
#include <queue>
#include <unordered_set>
#include <stack>
#include <map>
#include <cassert>
#include <unordered_map>

#define FILE "chvatal"

typedef long long ll;
typedef unsigned int ui;

using namespace std;

struct edge {
    int v, u, flow, max_flow, c;
};

void add_edge(int v, int u, int f, int c, vector<edge> &edges, vector<vector<int>> &g) {
//    cerr << v << ' ' << u << ' ' << f << ' ' << c << '\n';
    g[v].push_back((int) edges.size());
    edges.push_back({v, u, 0, f, c});
    g[u].push_back((int) edges.size());
    edges.push_back({u, v, 0, 0, -c});
}

const int INF = 2e8;

void ford_bellman(int s, vector<edge> &edges, vector<vector<int>> &g, vector<int> &d) {
    int n = (int) g.size();
    for (int i = 0; i < n; ++i) {
        d[i] = INF;
    }
    d[s] = 0;
    for (int i = 0; i < n; ++i) {
        bool any = false;
        for (int v = 0; v < n; ++v) {
            for (int id : g[v]) {
                edge e = edges[id];
                if (e.flow < e.max_flow && d[e.u] > d[e.v] + e.c) {
                    d[e.u] = d[e.v] + e.c;
                    any = true;
                }
            }
        }
        if (!any) {
            break;
        }
    }
}

bool dick_stra(int s, int t, vector<edge> &edges, vector<vector<int>> const &g,
               vector<int> &pot, vector<int> &path) {
    int n = (int) pot.size();
    vector<int> d(n, INF);
    d[s] = 0;
    vector<bool> used(n);
    vector<int> par(n, -1);
    for (int i = 0; i < n; ++i) {
        int v = -1;
        for (int j = 0; j < n; ++j) {
            if (!used[j] && (v == -1 || d[v] > d[j])) {
                v = j;
            }
        }
        used[v] = true;
        for (int id : g[v]) {
            edge e = edges[id];
            int dist = e.c + pot[v] - pot[e.u];
            if (e.flow < e.max_flow && d[e.u] > d[v] + dist) {
                d[e.u] = d[v] + dist;
                par[e.u] = id;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        pot[i] += d[i];
    }
    if (d[t] == INF) {
        return false;
    }
    int v = t;
    while (par[v] != -1) {
        path.push_back(par[v]);
        v = edges[par[v]].v;
    }
    return true;
}

struct task {
    int l, r, c;
};

int main() {
#if 0
    freopen("input.txt", "r", stdin);
#else
    //    freopen(FILE".in", "r", stdin);
    //    freopen(FILE".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;
    vector<task> tasks(n);
    for (int i = 0; i < n; ++i) {
        cin >> tasks[i].l >> tasks[i].r >> tasks[i].c;
        tasks[i].r += tasks[i].l - 1;
    }
    int cnt_vs = 2 * n + 3;
    vector<vector<int>> g(cnt_vs);
    vector<edge> edges;
    add_edge(0, 1, k, 0, edges, g);
    vector<int> edges_id(n);
    for (int i = 1; i <= n; ++i) {
        int v = 2 * i, u = 2 * i + 1;
        add_edge(1, v, 1, 0, edges, g);
        add_edge(u, cnt_vs - 1, 1, 0, edges, g);
        edges_id[i - 1] = (int) edges.size();
        add_edge(v, u, 1, -tasks[i - 1].c, edges, g);
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            task f = tasks[i], s = tasks[j];
            if (s.l > f.r) {
                int v = 2 * (i + 1) + 1;
                int u = 2 * (j + 1);
                add_edge(v, u, 1, 0, edges, g);
            }
        }
    }
    vector<int> pot(cnt_vs);
    ford_bellman(0, edges, g, pot);
    for (;;) {
        vector<int> path;
        if (!dick_stra(0, cnt_vs - 1, edges, g, pot, path)) {
            break;
        }
        int flow = INF;
        for (int id : path) {
            flow = min(flow, edges[id].max_flow - edges[id].flow);
        }
        for (int id : path) {
            edges[id].flow += flow;
            edges[id ^ 1].flow -= flow;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (edges[edges_id[i]].flow > 0) {
            cout << 1 << ' ';
        } else {
            cout << 0 << ' ';
        }
    }

    return 0;
}


#include <set>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <bitset>
#include <algorithm>
#include <queue>
#include <unordered_set>
#include <stack>
#include <map>
#include <cassert>
#include <unordered_map>

#define FILE "chvatal"

typedef long long ll;
typedef unsigned int ui;

using namespace std;

struct edge {
    int v, u, flow, max_flow, c;
};

void add_edge(int v, int u, int f, int c, vector<edge> &edges, vector<vector<int>> &g) {
//    cerr << v << ' ' << u << ' ' << f << ' ' << c << '\n';
    g[v].push_back((int) edges.size());
    edges.push_back({v, u, 0, f, c});
    g[u].push_back((int) edges.size());
    edges.push_back({u, v, 0, 0, -c});
}

const int INF = 2e8;

void ford_bellman(int s, vector<edge> &edges, vector<vector<int>> &g, vector<int> &d) {
    int n = (int) g.size();
    for (int i = 0; i < n; ++i) {
        d[i] = INF;
    }
    d[s] = 0;
    for (int i = 0; i < n; ++i) {
        bool any = false;
        for (int v = 0; v < n; ++v) {
            for (int id : g[v]) {
                edge e = edges[id];
                if (e.flow < e.max_flow && d[e.u] > d[e.v] + e.c) {
                    d[e.u] = d[e.v] + e.c;
                    any = true;
                }
            }
        }
        if (!any) {
            break;
        }
    }
}

bool dick_stra(int s, int t, vector<edge> &edges, vector<vector<int>> const &g,
               vector<int> &pot, vector<int> &path) {
    int n = (int) pot.size();
    vector<int> d(n, INF);
    d[s] = 0;
    vector<bool> used(n);
    vector<int> par(n, -1);
    for (int i = 0; i < n; ++i) {
        int v = -1;
        for (int j = 0; j < n; ++j) {
            if (!used[j] && (v == -1 || d[v] > d[j])) {
                v = j;
            }
        }
        used[v] = true;
        for (int id : g[v]) {
            edge e = edges[id];
            int dist = e.c + pot[v] - pot[e.u];
            if (e.flow < e.max_flow && d[e.u] > d[v] + dist) {
                d[e.u] = d[v] + dist;
                par[e.u] = id;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        pot[i] += d[i];
    }
    if (d[t] == INF) {
        return false;
    }
    int v = t;
    while (par[v] != -1) {
        path.push_back(par[v]);
        v = edges[par[v]].v;
    }
    return true;
}

struct task {
    int l, r, c;
};

int main() {
#if 0
    freopen("input.txt", "r", stdin);
#else
    //    freopen(FILE".in", "r", stdin);
    //    freopen(FILE".out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n, k;
    cin >> n >> k;
    vector<task> tasks(n);
    for (int i = 0; i < n; ++i) {
        cin >> tasks[i].l >> tasks[i].r >> tasks[i].c;
        tasks[i].r += tasks[i].l - 1;
    }
    int cnt_vs = 2 * n + 3;
    vector<vector<int>> g(cnt_vs);
    vector<edge> edges;
    add_edge(0, 1, k, 0, edges, g);
    vector<int> edges_id(n);
    for (int i = 1; i <= n; ++i) {
        int v = 2 * i, u = 2 * i + 1;
        add_edge(1, v, 1, 0, edges, g);
        add_edge(u, cnt_vs - 1, 1, 0, edges, g);
        edges_id[i - 1] = (int) edges.size();
        add_edge(v, u, 1, -tasks[i - 1].c, edges, g);
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            task f = tasks[i], s = tasks[j];
            if (s.l > f.r) {
                int v = 2 * (i + 1) + 1;
                int u = 2 * (j + 1);
                add_edge(v, u, 1, 0, edges, g);
            }
        }
    }
    vector<int> pot(cnt_vs);
    ford_bellman(0, edges, g, pot);
    for (;;) {
        vector<int> path;
        if (!dick_stra(0, cnt_vs - 1, edges, g, pot, path)) {
            break;
        }
        int flow = INF;
        for (int id : path) {
            flow = min(flow, edges[id].max_flow - edges[id].flow);
        }
        for (int id : path) {
            edges[id].flow += flow;
            edges[id ^ 1].flow -= flow;
        }
    }
    for (int i = 0; i < n; ++i) {
        if (edges[edges_id[i]].flow > 0) {
            cout << 1 << ' ';
        } else {
            cout << 0 << ' ';
        }
    }

    return 0;