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

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

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

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

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

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

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

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

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

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

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

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

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

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


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;

const int inf = (int)1e+9 + 7;

struct edge {
	int to, f, c, cost;

	edge() = default;

	edge(int nt, int fn, int cn, int ccn) {
		to = nt;
		f = fn;
		c = cn;
		cost = ccn;
	}
};

int s, t;
vector < vector<int> > g;
vector <int> f;
vector <edge> lst;

bool push_flow() {
	static int iter = -1;
	iter++;
	vector <int> d(g.size(), inf);
	vector < pair<int, int> > par(g.size(), make_pair(-1, -1));
	d[s] = 0;

	if (!iter) {
		for (int t = 0; t < (int)g.size(); t++) {
			bool any = false;
			for (int i = 0; i < (int)g.size(); i++) {
				if (d[i] == inf)
					continue;
				for (int j = 0; j < (int)g[i].size(); j++) {
					int num = g[i][j];
					if (lst[num].f == lst[num].c)
						continue;
					if (d[lst[num].to] > d[i] + lst[num].cost) {
						any = true;
						d[lst[num].to] = d[i] + lst[num].cost;
						par[lst[num].to] = make_pair(i, num);
					}
				}
			}
			if (!any)
				break;
		}
	} else {
		vector <bool> inq(d.size());
		for (int i = 0; i < (int)d.size(); i++) {
			int minu = inf, v = -1;
			for (int j = 0; j < (int)d.size(); j++) {
				if (!inq[j] && d[j] < minu) {
					minu = d[j];
					v = j;
				}
			}
			if (v == -1)
				break;
			inq[v] = true;
			for (int j = 0; j < (int)g[v].size(); j++) {
				int num = g[v][j];
				if (lst[num].f == lst[num].c)
					continue;
				if (d[lst[num].to] > d[v] + lst[num].cost + f[v] - f[lst[num].to]) {
					d[lst[num].to] = d[v] + lst[num].cost + f[v] - f[lst[num].to];
					par[lst[num].to] = make_pair(v, num);
				}
			}
		}
	}
	for (int i = 0; i < (int)f.size(); i++)
		f[i] += d[i];

	int add = inf;
	pair <int, int> cur = make_pair(t, -1);
	vector <int> path;
	while (true) {
		if (cur.second != -1) {
			path.push_back(cur.second);
			add = min(add, lst[cur.second].c - lst[cur.second].f);
		}
		if (par[cur.first].first == -1)
			break;
		cur = par[cur.first];
	}
	for (int i = 0; i < (int)path.size(); i++) {
		lst[path[i]].f += add;
		lst[path[i] ^ 1].f -= add;
	}
	return (!path.empty());
}

struct task {
	int l, t, cost, num;

	task() = default;

	task(int nl, int nt, int nc, int nn) {
		l = nl;
		t = nt;
		cost = nc;
		num = nn;
	}

	bool operator<(const task& b) {
		if (l != b.l)
			return l < b.l;
		else
			return num < b.num;
	}
};

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, k, a, b, numeric = 0;
	cin >> n >> k;

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

	vector <task> arr(n);
	for (int i = 0; i < n; i++) {
		cin >> arr[i].l >> arr[i].t >> arr[i].cost;
		arr[i].num = i;
	}

	g.resize(2 * n + 3);
	f.resize(2 * n + 3);
	lst.resize(2 * (n * n + 2 * n + 1));

	for (int i = 0; i < n; i++) {
		lst[numeric] = edge(i + 1, 0, 1, 0);
		g[s].push_back(numeric++);
		lst[numeric] = edge(s, 0, 0, 0);
		g[i + 1].push_back(numeric++);
	}
	for (int i = 0; i < n; i++) {
		a = i + 1; b = i + 1 + n;
		lst[numeric] = edge(b, 0, 1, -arr[i].cost);
		g[a].push_back(numeric++);
		lst[numeric] = edge(a, 0, 0, arr[i].cost);
		g[b].push_back(numeric++);
	}
	sort(arr.begin(), arr.end());
	for (int i = 0; i < n; i++) {
		a = arr[i].num + 1;
		if (i < n - 1) {
			b = arr[i + 1].num + 1;
		} else {
			b = t;
		}
		lst[numeric] = edge(b, 0, 1, inf);
		g[a].push_back(numeric++);
		lst[numeric] = edge(a, 0, 0, inf);
		g[b].push_back(numeric++);
	}
	for (int i = 0; i < n; i++) {
		a = arr[i].num + 1 + n;
		int ptr = lower_bound(arr.begin(), arr.end(), task(arr[i].l + arr[i].t, 0, 0, -1)) - arr.begin();
		if (ptr < (int)arr.size()) {
			b = arr[ptr].num + 1;
		} else {
			b = t;
		}
		lst[numeric] = edge(b, 0, 1, 0);
		g[a].push_back(numeric++);
		lst[numeric] = edge(a, 0, 0, 0);
		g[b].push_back(numeric++);
	}

	lst[numeric] = edge(t + 1, 0, k, 0);
	g[t].push_back(numeric++);
	lst[numeric] = edge(t, 0, 0, 0);
	g[t + 1].push_back(numeric++);
	t++;
	lst.resize(numeric);

	while (push_flow()) {}

	vector <int> ans(n);
	for (int i = n + 1; i <= 2 * n; i++) {
		for (int j = 0; j < (int)g[i].size(); j++) {
			int num = g[i][j];
			if (lst[num].f == 1) {
				ans[i - n - 1] = 1;
			}
		}
	}

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

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;

const int inf = (int)1e+9 + 7;

struct edge {
	int to, f, c, cost;

	edge() = default;

	edge(int nt, int fn, int cn, int ccn) {
		to = nt;
		f = fn;
		c = cn;
		cost = ccn;
	}
};

int s, t;
vector < vector<int> > g;
vector <int> f;
vector <edge> lst;

bool push_flow() {
	static int iter = -1;
	iter++;
	vector <int> d(g.size(), inf);
	vector < pair<int, int> > par(g.size(), make_pair(-1, -1));
	d[s] = 0;

	if (!iter) {
		for (int t = 0; t < (int)g.size(); t++) {
			bool any = false;
			for (int i = 0; i < (int)g.size(); i++) {
				if (d[i] == inf)
					continue;
				for (int j = 0; j < (int)g[i].size(); j++) {
					int num = g[i][j];
					if (lst[num].f == lst[num].c)
						continue;
					if (d[lst[num].to] > d[i] + lst[num].cost) {
						any = true;
						d[lst[num].to] = d[i] + lst[num].cost;
						par[lst[num].to] = make_pair(i, num);
					}
				}
			}
			if (!any)
				break;
		}
	} else {
		set < pair<int, int> > q;
		q.insert(make_pair(d[s], s));
		while (!q.empty()) {
			int v = q.begin()->second;
			q.erase(q.begin());
			for (int i = 0; i < (int)g[v].size(); i++) {
				int num = g[v][i];
				if (lst[num].f == lst[num].c)
					continue;
				if (d[lst[num].to] > d[v] + lst[num].cost + f[v] - f[lst[num].to]) {
					q.erase(make_pair(d[lst[num].to], lst[num].to));
					d[lst[num].to] = d[v] + lst[num].cost + f[v] - f[lst[num].to];
					par[lst[num].to] = make_pair(v, num);
					q.insert(make_pair(d[lst[num].to], lst[num].to));
				}
			}
		}
	}
	for (int i = 0; i < (int)f.size(); i++)
		f[i] += d[i];

	int add = inf;
	pair <int, int> cur = make_pair(t, -1);
	vector <int> path;
	while (true) {
		if (cur.second != -1) {
			path.push_back(cur.second);
			add = min(add, lst[cur.second].c - lst[cur.second].f);
		}
		if (par[cur.first].first == -1)
			break;
		cur = par[cur.first];
	}
	for (int i = 0; i < (int)path.size(); i++) {
		lst[path[i]].f += add;
		lst[path[i] ^ 1].f -= add;
	}
	return (!path.empty());
}

vector<int> gm;
vector <int> ans;
int cur_rob = 0;

void dfs(int v) {
	ans[v] = cur_rob;
	if (gm[v] != -1)
		dfs(gm[v]);
}

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, k, a, b, numeric = 0;
	cin >> n >> k;

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

	vector < pair< pair<int, int>, int> > arr(n);
	for (int i = 0; i < n; i++) {
		cin >> arr[i].first.first >> arr[i].first.second >> arr[i].second;
	}

	g.resize(2 * n + 3);
	f.resize(2 * n + 3);
	lst.resize(2 * (n * n + 2 * n + 1));

	for (int i = 0; i < n; i++) {
		lst[numeric] = edge(i + 1, 0, 1, 0);
		g[s].push_back(numeric++);
		lst[numeric] = edge(s, 0, 0, 0);
		g[i + 1].push_back(numeric++);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) {
				a = i + 1; b = i + 1 + n;
				lst[numeric] = edge(b, 0, 1, -arr[i].second);
				g[a].push_back(numeric++);
				lst[numeric] = edge(a, 0, 0, arr[i].second);
				g[b].push_back(numeric++);
				continue;
			}
			if (arr[i].first.first + arr[i].first.second - 1 >= arr[j].first.first)
				continue;
			a = i + 1 + n; b = j + 1;
			lst[numeric] = edge(b, 0, 1, 0);
			g[a].push_back(numeric++);
			lst[numeric] = edge(a, 0, 0, 0);
			g[b].push_back(numeric++);
		}
	}
	for (int i = 0; i < n; i++) {
		lst[numeric] = edge(t, 0, 1, 0);
		g[i + 1 + n].push_back(numeric++);
		lst[numeric] = edge(i + 1 + n, 0, 0, 0);
		g[t].push_back(numeric++);
	}

	lst[numeric] = edge(t + 1, 0, k, 0);
	g[t].push_back(numeric++);
	lst[numeric] = edge(t, 0, 0, 0);
	g[t + 1].push_back(numeric++);
	t++;

	while (push_flow()) {}

	ans.resize(n, -1);
	gm.resize(n, -1);
	vector <int> degin(n);
	vector <bool> cover(n);
	for (int i = n + 1; i <= 2 * n; i++) {
		for (int j = 0; j < (int)g[i].size(); j++) {
			int num = g[i][j];
			if (lst[num].f == 1) {
				cover[i - n - 1] = true;
				if (lst[num].to != t - 1) {
					gm[i - n - 1] = lst[num].to - 1;
					degin[gm[i - n - 1]]++;
				}
			}
		}
	}

	for (int i = 0; i < n; i++) {
		if (degin[i] == 0 && cover[i]) {
			dfs(i);
			cur_rob++;
		}
	}

	for (int i = 0; i < n; i++)
		cout << (int)(ans[i] > -1) << " ";

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;

const int inf = (int)1e+9 + 7;

struct edge {
	int to, f, c, cost;

	edge() = default;

	edge(int nt, int fn, int cn, int ccn) {
		to = nt;
		f = fn;
		c = cn;
		cost = ccn;
	}
};

int s, t;
vector < vector<int> > g;
vector <edge> lst;

bool push_flow() {
	vector <int> d(g.size(), inf);
	vector < pair<int, int> > par(g.size(), make_pair(-1, -1));
	d[s] = 0;

	for (int t = 0; t < (int)g.size(); t++) {
		bool any = false;
		for (int i = 0; i < (int)g.size(); i++) {
			if (d[i] == inf)
				continue;
			for (int j = 0; j < (int)g[i].size(); j++) {
				int num = g[i][j];
				if (lst[num].f == lst[num].c)
					continue;
				if (d[lst[num].to] > d[i] + lst[num].cost) {
					any = true;
					d[lst[num].to] = d[i] + lst[num].cost;
					par[lst[num].to] = make_pair(i, num);
				}
			}
		}
		if (!any)
			break;
	}

	int add = inf;
	pair <int, int> cur = make_pair(t, -1);
	vector <int> path;
	while (true) {
		if (cur.second != -1) {
			path.push_back(cur.second);
			add = min(add, lst[cur.second].c - lst[cur.second].f);
		}
		if (par[cur.first].first == -1)
			break;
		cur = par[cur.first];
	}
	for (int i = 0; i < (int)path.size(); i++) {
		lst[path[i]].f += add;
		lst[path[i] ^ 1].f -= add;
	}
	return (!path.empty());
}

vector<int> gm;
vector <int> ans;
int cur_rob = 0;

void dfs(int v) {
	ans[v] = cur_rob;
	if (gm[v] != -1)
		dfs(gm[v]);
}

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, k, a, b, numeric = 0;
	cin >> n >> k;

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

	vector < pair< pair<int, int>, int> > arr(n);
	for (int i = 0; i < n; i++) {
		cin >> arr[i].first.first >> arr[i].first.second >> arr[i].second;
	}

	g.resize(2 * n + 3);
	lst.resize(2 * (n * n + 2 * n + 1));

	for (int i = 0; i < n; i++) {
		lst[numeric] = edge(i + 1, 0, 1, 0);
		g[s].push_back(numeric++);
		lst[numeric] = edge(s, 0, 0, 0);
		g[i + 1].push_back(numeric++);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) {
				a = i + 1; b = i + 1 + n;
				lst[numeric] = edge(b, 0, 1, -arr[i].second);
				g[a].push_back(numeric++);
				lst[numeric] = edge(a, 0, 0, arr[i].second);
				g[b].push_back(numeric++);
				continue;
			}
			if (arr[i].first.first + arr[i].first.second - 1 >= arr[j].first.first)
				continue;
			a = i + 1 + n; b = j + 1;
			lst[numeric] = edge(b, 0, 1, 0);
			g[a].push_back(numeric++);
			lst[numeric] = edge(a, 0, 0, 0);
			g[b].push_back(numeric++);
		}
	}
	for (int i = 0; i < n; i++) {
		lst[numeric] = edge(t, 0, 1, 0);
		g[i + 1 + n].push_back(numeric++);
		lst[numeric] = edge(i + 1 + n, 0, 0, 0);
		g[t].push_back(numeric++);
	}

	lst[numeric] = edge(t + 1, 0, k, 0);
	g[t].push_back(numeric++);
	lst[numeric] = edge(t, 0, 0, 0);
	g[t + 1].push_back(numeric++);
	t++;

	while (push_flow()) {}

	ans.resize(n, -1);
	gm.resize(n, -1);
	vector <int> degin(n);
	vector <bool> cover(n);
	for (int i = n + 1; i <= 2 * n; i++) {
		for (int j = 0; j < (int)g[i].size(); j++) {
			int num = g[i][j];
			if (lst[num].f == 1) {
				cover[i - n - 1] = true;
				if (lst[num].to != t - 1) {
					gm[i - n - 1] = lst[num].to - 1;
					degin[gm[i - n - 1]]++;
				}
			}
		}
	}

	for (int i = 0; i < n; i++) {
		if (degin[i] == 0 && cover[i]) {
			dfs(i);
			cur_rob++;
		}
	}

	for (int i = 0; i < n; i++)
		cout << (int)(ans[i] > -1) << " ";

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;

const int inf = (int)1e+9 + 7;

struct edge {
	int to, f, c, cost;

	edge() = default;

	edge(int nt, int fn, int cn, int ccn) {
		to = nt;
		f = fn;
		c = cn;
		cost = ccn;
	}
};

int s, t;
vector < vector<int> > g;
vector <edge> lst;

bool push_flow() {
	vector <int> d(g.size(), inf);
	vector < pair<int, int> > par(g.size(), make_pair(-1, -1));
	d[s] = 0;

	for (int t = 0; t < (int)g.size(); t++) {
		bool any = false;
		for (int i = 0; i < (int)g.size(); i++) {
			if (d[i] == inf)
				continue;
			for (int j = 0; j < (int)g[i].size(); j++) {
				int num = g[i][j];
				if (lst[num].f == lst[num].c)
					continue;
				if (d[lst[num].to] > d[i] + lst[num].cost) {
					any = true;
					d[lst[num].to] = d[i] + lst[num].cost;
					par[lst[num].to] = make_pair(i, num);
				}
			}
		}
		if (!any)
			break;
	}

	int add = inf;
	pair <int, int> cur = make_pair(t, -1);
	vector <int> path;
	while (true) {
		if (cur.second != -1) {
			path.push_back(cur.second);
			add = min(add, lst[cur.second].c - lst[cur.second].f);
		}
		if (par[cur.first].first == -1)
			break;
		cur = par[cur.first];
	}
	for (int i = 0; i < (int)path.size(); i++) {
		lst[path[i]].f += add;
		lst[path[i] ^ 1].f -= add;
	}
	return (!path.empty());
}

struct task {
	int l, t, cost, num;

	task() = default;

	task(int nl, int nt, int nc, int nn) {
		l = nl;
		t = nt;
		cost = nc;
		num = nn;
	}

	bool operator<(const task& b) {
		if (l != b.l)
			return l < b.l;
		else
			return num < b.num;
	}
};

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, k, a, b, numeric = 0;
	cin >> n >> k;

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

	vector <task> arr(n);
	for (int i = 0; i < n; i++) {
		cin >> arr[i].l >> arr[i].t >> arr[i].cost;
		arr[i].num = i;
	}

	g.resize(2 * n + 3);
	lst.resize(2 * (n * n + 2 * n + 1));

	for (int i = 0; i < n; i++) {
		lst[numeric] = edge(i + 1, 0, 1, 0);
		g[s].push_back(numeric++);
		lst[numeric] = edge(s, 0, 0, 0);
		g[i + 1].push_back(numeric++);
	}
	for (int i = 0; i < n; i++) {
		a = i + 1; b = i + 1 + n;
		lst[numeric] = edge(b, 0, 1, -arr[i].cost);
		g[a].push_back(numeric++);
		lst[numeric] = edge(a, 0, 0, arr[i].cost);
		g[b].push_back(numeric++);
	}
	sort(arr.begin(), arr.end());
	for (int i = 0; i < n; i++) {
		a = arr[i].num + 1;
		if (i < n - 1) {
			b = arr[i + 1].num + 1;
		} else {
			b = t;
		}
		lst[numeric] = edge(b, 0, k, 0);
		g[a].push_back(numeric++);
		lst[numeric] = edge(a, 0, 0, 0);
		g[b].push_back(numeric++);
	}
	for (int i = 0; i < n; i++) {
		a = arr[i].num + 1 + n;
		int ptr = lower_bound(arr.begin(), arr.end(), task(arr[i].l + arr[i].t, 0, 0, -1)) - arr.begin();
		if (ptr < (int)arr.size()) {
			b = arr[ptr].num + 1;
		} else {
			b = t;
		}
		lst[numeric] = edge(b, 0, 1, 0);
		g[a].push_back(numeric++);
		lst[numeric] = edge(a, 0, 0, 0);
		g[b].push_back(numeric++);
	}

	lst[numeric] = edge(t + 1, 0, k, 0);
	g[t].push_back(numeric++);
	lst[numeric] = edge(t, 0, 0, 0);
	g[t + 1].push_back(numeric++);
	t++;
	lst.resize(numeric);

	while (push_flow()) {}

	vector <int> ans(n);
	for (int i = n + 1; i <= 2 * n; i++) {
		for (int j = 0; j < (int)g[i].size(); j++) {
			int num = g[i][j];
			if (lst[num].f == 1) {
				ans[i - n - 1] = 1;
			}
		}
	}

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

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;

const int inf = (int)1e+9 + 7;

struct edge {
	int to, f, c, cost;

	edge() = default;

	edge(int nt, int fn, int cn, int ccn) {
		to = nt;
		f = fn;
		c = cn;
		cost = ccn;
	}
};

int s, t;
vector < vector<int> > g;
vector <edge> lst;

bool push_flow() {
	vector <int> d(g.size(), inf);
	vector < pair<int, int> > par(g.size(), make_pair(-1, -1));
	d[s] = 0;

	for (int t = 0; t < (int)g.size(); t++) {
		bool any = false;
		for (int i = 0; i < (int)g.size(); i++) {
			if (d[i] == inf)
				continue;
			for (int j = 0; j < (int)g[i].size(); j++) {
				int num = g[i][j];
				if (lst[num].f == lst[num].c)
					continue;
				if (d[lst[num].to] > d[i] + lst[num].cost) {
					any = true;
					d[lst[num].to] = d[i] + lst[num].cost;
					par[lst[num].to] = make_pair(i, num);
				}
			}
		}
		if (!any)
			break;
	}

	int add = inf;
	pair <int, int> cur = make_pair(t, -1);
	vector <int> path;
	while (true) {
		if (cur.second != -1) {
			path.push_back(cur.second);
			add = min(add, lst[cur.second].c - lst[cur.second].f);
		}
		if (par[cur.first].first == -1)
			break;
		cur = par[cur.first];
	}
	for (int i = 0; i < (int)path.size(); i++) {
		lst[path[i]].f += add;
		lst[path[i] ^ 1].f -= add;
	}
	return (!path.empty());
}

vector<int> gm;
vector <int> ans;
int cur_rob = 0;

void dfs(int v) {
	ans[v] = cur_rob;
	if (gm[v] != -1)
		dfs(gm[v]);
}

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, k, a, b, cost, numeric = 0;
	cin >> n >> k;

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

	vector < pair< pair<int, int>, int> > arr(n);
	for (int i = 0; i < n; i++) {
		cin >> arr[i].first.first >> arr[i].first.second >> arr[i].second;
	}

	g.resize(2 * n + 3);
	lst.resize(2 * (n * n + 2 * n + 1));

	for (int i = 0; i < n; i++) {
		lst[numeric] = edge(i + 1, 0, 1, 0);
		g[s].push_back(numeric++);
		lst[numeric] = edge(s, 0, 0, 0);
		g[i + 1].push_back(numeric++);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (arr[i].first.first + arr[i].first.second - 1 >= arr[j].first.first)
				continue;
			a = i + 1; b = j + 1 + n; cost = -arr[j].second;
			lst[numeric] = edge(b, 0, 1, cost);
			g[a].push_back(numeric++);
			lst[numeric] = edge(a, 0, 0, -cost);
			g[b].push_back(numeric++);
		}
	}
	for (int i = 0; i < n; i++) {
		lst[numeric] = edge(t, 0, 1, 0);
		g[i + 1 + n].push_back(numeric++);
		lst[numeric] = edge(i + 1 + n, 0, 0, 0);
		g[t].push_back(numeric++);
	}

	lst[numeric] = edge(t + 1, 0, k, 0);
	g[t].push_back(numeric++);
	lst[numeric] = edge(t, 0, 0, 0);
	g[t + 1].push_back(numeric++);
	t++;

	while (push_flow()) {}

	ans.resize(n, -1);
	gm.resize(n, -1);
	vector <int> degin(n);
	vector <bool> cover(n);
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < (int)g[i].size(); j++) {
			int num = g[i][j];
			if (lst[num].f == 1) {
				cover[i - 1] = true;
				gm[i - 1] = lst[num].to - n - 1;
				degin[gm[i - 1]]++;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		if (degin[i] == 0 && cover[i]) {
			dfs(i);
			cur_rob++;
		}
	}

	for (int i = 0; i < n; i++)
		cout << (int)(ans[i] > -1) << " ";

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;

const int inf = (int)1e+9 + 7;

struct edge {
	int to, f, c, cost;

	edge() = default;

	edge(int nt, int fn, int cn, int ccn) {
		to = nt;
		f = fn;
		c = cn;
		cost = ccn;
	}
};

int s, t;
vector < vector<int> > g;
vector <int> f;
vector <edge> lst;

bool push_flow() {
	static int iter = -1;
	iter++;
	vector <int> d(g.size(), inf);
	vector < pair<int, int> > par(g.size(), make_pair(-1, -1));
	d[s] = 0;

	if (!iter) {
		for (int t = 0; t < (int)g.size(); t++) {
			bool any = false;
			for (int i = 0; i < (int)g.size(); i++) {
				if (d[i] == inf)
					continue;
				for (int j = 0; j < (int)g[i].size(); j++) {
					int num = g[i][j];
					if (lst[num].f == lst[num].c)
						continue;
					if (d[lst[num].to] > d[i] + lst[num].cost) {
						any = true;
						d[lst[num].to] = d[i] + lst[num].cost;
						par[lst[num].to] = make_pair(i, num);
					}
				}
			}
			if (!any)
				break;
		}
	} else {
		vector <bool> inq(d.size());
		for (int i = 0; i < (int)d.size(); i++) {
			int minu = inf, v = -1;
			for (int j = 0; j < (int)d.size(); j++) {
				if (!inq[j] && d[j] < minu) {
					minu = d[j];
					v = j;
				}
			}
			if (v == -1)
				break;
			inq[v] = true;
			for (int j = 0; j < (int)g[v].size(); j++) {
				int num = g[v][j];
				if (lst[num].f == lst[num].c)
					continue;
				if (d[lst[num].to] > d[v] + lst[num].cost + f[v] - f[lst[num].to]) {
					d[lst[num].to] = d[v] + lst[num].cost + f[v] - f[lst[num].to];
					par[lst[num].to] = make_pair(v, num);
				}
			}
		}
	}
	for (int i = 0; i < (int)f.size(); i++)
		f[i] += d[i];

	int add = inf;
	pair <int, int> cur = make_pair(t, -1);
	vector <int> path;
	while (true) {
		if (cur.second != -1) {
			path.push_back(cur.second);
			add = min(add, lst[cur.second].c - lst[cur.second].f);
		}
		if (par[cur.first].first == -1)
			break;
		cur = par[cur.first];
	}
	for (int i = 0; i < (int)path.size(); i++) {
		lst[path[i]].f += add;
		lst[path[i] ^ 1].f -= add;
	}
	return (!path.empty());
}

struct task {
	int l, t, cost, num;

	task() = default;

	task(int nl, int nt, int nc, int nn) {
		l = nl;
		t = nt;
		cost = nc;
		num = nn;
	}

	bool operator<(const task& b) {
		if (l != b.l)
			return l < b.l;
		else
			return num < b.num;
	}
};

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, k, a, b, numeric = 0;
	cin >> n >> k;

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

	vector <task> arr(n);
	for (int i = 0; i < n; i++) {
		cin >> arr[i].l >> arr[i].t >> arr[i].cost;
		arr[i].num = i;
	}

	g.resize(2 * n + 3);
	f.resize(2 * n + 3);
	lst.resize(2 * (n * n + 2 * n + 1));

	for (int i = 0; i < n; i++) {
		lst[numeric] = edge(i + 1, 0, 1, 0);
		g[s].push_back(numeric++);
		lst[numeric] = edge(s, 0, 0, 0);
		g[i + 1].push_back(numeric++);
	}
	for (int i = 0; i < n; i++) {
		a = i + 1; b = i + 1 + n;
		lst[numeric] = edge(b, 0, 1, -arr[i].cost);
		g[a].push_back(numeric++);
		lst[numeric] = edge(a, 0, 0, arr[i].cost);
		g[b].push_back(numeric++);
	}
	sort(arr.begin(), arr.end());
	for (int i = 0; i < n; i++) {
		a = arr[i].num + 1;
		if (i < n - 1) {
			b = arr[i + 1].num + 1;
		} else {
			b = t;
		}
		lst[numeric] = edge(b, 0, inf, 0);
		g[a].push_back(numeric++);
		lst[numeric] = edge(a, 0, 0, 0);
		g[b].push_back(numeric++);
	}
	for (int i = 0; i < n; i++) {
		a = arr[i].num + 1 + n;
		int ptr = lower_bound(arr.begin(), arr.end(), task(arr[i].l + arr[i].t, 0, 0, -1)) - arr.begin();
		if (ptr < (int)arr.size()) {
			b = arr[ptr].num + 1;
		} else {
			b = t;
		}
		lst[numeric] = edge(b, 0, 1, 0);
		g[a].push_back(numeric++);
		lst[numeric] = edge(a, 0, 0, 0);
		g[b].push_back(numeric++);
	}

	lst[numeric] = edge(t + 1, 0, k, 0);
	g[t].push_back(numeric++);
	lst[numeric] = edge(t, 0, 0, 0);
	g[t + 1].push_back(numeric++);
	t++;
	lst.resize(numeric);

	while (push_flow()) {}

	vector <int> ans(n);
	for (int i = n + 1; i <= 2 * n; i++) {
		for (int j = 0; j < (int)g[i].size(); j++) {
			int num = g[i][j];
			if (lst[num].f == 1) {
				ans[i - n - 1] = 1;
			}
		}
	}

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

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;

const int inf = (int)1e+9 + 7;

struct edge {
	int to, f, c, cost;

	edge() = default;

	edge(int nt, int fn, int cn, int ccn) {
		to = nt;
		f = fn;
		c = cn;
		cost = ccn;
	}
};

int s, t;
vector < vector<int> > g;
vector <int> f;
vector <edge> lst;

bool push_flow() {
	static int iter = -1;
	iter++;
	vector <int> d(g.size(), inf);
	vector < pair<int, int> > par(g.size(), make_pair(-1, -1));
	d[s] = 0;

	if (!iter) {
		for (int t = 0; t < (int)g.size(); t++) {
			bool any = false;
			for (int i = 0; i < (int)g.size(); i++) {
				if (d[i] == inf)
					continue;
				for (int j = 0; j < (int)g[i].size(); j++) {
					int num = g[i][j];
					if (lst[num].f == lst[num].c)
						continue;
					if (d[lst[num].to] > d[i] + lst[num].cost) {
						any = true;
						d[lst[num].to] = d[i] + lst[num].cost;
						par[lst[num].to] = make_pair(i, num);
					}
				}
			}
			if (!any)
				break;
		}
	} else {
		vector <bool> inq(d.size());
		for (int i = 0; i < (int)d.size(); i++) {
			int minu = inf, v = -1;
			for (int j = 0; j < (int)d.size(); j++) {
				if (!inq[j] && d[j] < minu) {
					minu = d[j];
					v = j;
				}
			}
			if (v == -1)
				break;
			inq[v] = true;
			for (int j = 0; j < (int)g[v].size(); j++) {
				int num = g[v][j];
				if (lst[num].f == lst[num].c)
					continue;
				if (d[lst[num].to] > d[v] + lst[num].cost + f[v] - f[lst[num].to]) {
					d[lst[num].to] = d[v] + lst[num].cost + f[v] - f[lst[num].to];
					par[lst[num].to] = make_pair(v, num);
				}
			}
		}
	}
	for (int i = 0; i < (int)f.size(); i++)
		f[i] += d[i];

	int add = inf;
	pair <int, int> cur = make_pair(t, -1);
	vector <int> path;
	while (true) {
		if (cur.second != -1) {
			path.push_back(cur.second);
			add = min(add, lst[cur.second].c - lst[cur.second].f);
		}
		if (par[cur.first].first == -1)
			break;
		cur = par[cur.first];
	}
	for (int i = 0; i < (int)path.size(); i++) {
		lst[path[i]].f += add;
		lst[path[i] ^ 1].f -= add;
	}
	return (!path.empty());
}

vector<int> gm;
vector <int> ans;
int cur_rob = 0;

void dfs(int v) {
	ans[v] = cur_rob;
	if (gm[v] != -1)
		dfs(gm[v]);
}

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, k, a, b, numeric = 0;
	cin >> n >> k;

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

	vector < pair< pair<int, int>, int> > arr(n);
	for (int i = 0; i < n; i++) {
		cin >> arr[i].first.first >> arr[i].first.second >> arr[i].second;
	}

	g.resize(2 * n + 3);
	f.resize(2 * n + 3);
	lst.resize(2 * (n * n + 2 * n + 1));

	for (int i = 0; i < n; i++) {
		lst[numeric] = edge(i + 1, 0, 1, 0);
		g[s].push_back(numeric++);
		lst[numeric] = edge(s, 0, 0, 0);
		g[i + 1].push_back(numeric++);
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i == j) {
				a = i + 1; b = i + 1 + n;
				lst[numeric] = edge(b, 0, 1, -arr[i].second);
				g[a].push_back(numeric++);
				lst[numeric] = edge(a, 0, 0, arr[i].second);
				g[b].push_back(numeric++);
				continue;
			}
			if (arr[i].first.first + arr[i].first.second - 1 >= arr[j].first.first)
				continue;
			a = i + 1 + n; b = j + 1;
			lst[numeric] = edge(b, 0, 1, 0);
			g[a].push_back(numeric++);
			lst[numeric] = edge(a, 0, 0, 0);
			g[b].push_back(numeric++);
		}
	}
	for (int i = 0; i < n; i++) {
		lst[numeric] = edge(t, 0, 1, 0);
		g[i + 1 + n].push_back(numeric++);
		lst[numeric] = edge(i + 1 + n, 0, 0, 0);
		g[t].push_back(numeric++);
	}

	lst[numeric] = edge(t + 1, 0, k, 0);
	g[t].push_back(numeric++);
	lst[numeric] = edge(t, 0, 0, 0);
	g[t + 1].push_back(numeric++);
	t++;

	while (push_flow()) {}

	ans.resize(n, -1);
	gm.resize(n, -1);
	vector <int> degin(n);
	vector <bool> cover(n);
	for (int i = n + 1; i <= 2 * n; i++) {
		for (int j = 0; j < (int)g[i].size(); j++) {
			int num = g[i][j];
			if (lst[num].f == 1) {
				cover[i - n - 1] = true;
				if (lst[num].to != t - 1) {
					gm[i - n - 1] = lst[num].to - 1;
					degin[gm[i - n - 1]]++;
				}
			}
		}
	}

	for (int i = 0; i < n; i++) {
		if (degin[i] == 0 && cover[i]) {
			dfs(i);
			cur_rob++;
		}
	}

	for (int i = 0; i < n; i++)
		cout << (int)(ans[i] > -1) << " ";

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;

const int inf = (int)1e+9 + 7;

struct edge {
	int to, f, c, cost;

	edge() = default;

	edge(int nt, int fn, int cn, int ccn) {
		to = nt;
		f = fn;
		c = cn;
		cost = ccn;
	}
};

int s, t;
vector < vector<int> > g;
vector <int> f;
vector <edge> lst;

bool push_flow() {
	static int iter = -1;
	iter++;
	vector <int> d(g.size(), inf);
	vector < pair<int, int> > par(g.size(), make_pair(-1, -1));
	d[s] = 0;

	if (!iter) {
		for (int t = 0; t < (int)g.size(); t++) {
			bool any = false;
			for (int i = 0; i < (int)g.size(); i++) {
				if (d[i] == inf)
					continue;
				for (int j = 0; j < (int)g[i].size(); j++) {
					int num = g[i][j];
					if (lst[num].f == lst[num].c)
						continue;
					if (d[lst[num].to] > d[i] + lst[num].cost) {
						any = true;
						d[lst[num].to] = d[i] + lst[num].cost;
						par[lst[num].to] = make_pair(i, num);
					}
				}
			}
			if (!any)
				break;
		}
	} else {
		vector <bool> inq(d.size());
		for (int i = 0; i < (int)d.size(); i++) {
			int minu = inf, v = -1;
			for (int j = 0; j < (int)d.size(); j++) {
				if (!inq[j] && d[j] < minu) {
					minu = d[j];
					v = j;
				}
			}
			if (v == -1)
				break;
			inq[v] = true;
			for (int j = 0; j < (int)g[v].size(); j++) {
				int num = g[v][j];
				if (lst[num].f == lst[num].c)
					continue;
				if (d[lst[num].to] > d[v] + lst[num].cost + f[v] - f[lst[num].to]) {
					d[lst[num].to] = d[v] + lst[num].cost + f[v] - f[lst[num].to];
					par[lst[num].to] = make_pair(v, num);
				}
			}
		}
	}
	for (int i = 0; i < (int)f.size(); i++)
		f[i] += d[i];

	int add = inf;
	pair <int, int> cur = make_pair(t, -1);
	vector <int> path;
	while (true) {
		if (cur.second != -1) {
			path.push_back(cur.second);
			add = min(add, lst[cur.second].c - lst[cur.second].f);
		}
		if (par[cur.first].first == -1)
			break;
		cur = par[cur.first];
	}
	for (int i = 0; i < (int)path.size(); i++) {
		lst[path[i]].f += add;
		lst[path[i] ^ 1].f -= add;
	}
	return (!path.empty());
}

struct task {
	int l, t, cost, num;

	task() = default;

	task(int nl, int nt, int nc, int nn) {
		l = nl;
		t = nt;
		cost = nc;
		num = nn;
	}

	bool operator<(const task& b) {
		if (l != b.l)
			return l < b.l;
		else
			return num < b.num;
	}
};

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, k, a, b, numeric = 0;
	cin >> n >> k;

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

	vector <task> arr(n);
	for (int i = 0; i < n; i++) {
		cin >> arr[i].l >> arr[i].t >> arr[i].cost;
		arr[i].num = i;
	}

	g.resize(2 * n + 3);
	f.resize(2 * n + 3);
	lst.resize(2 * (n * n + 2 * n + 1));

	for (int i = 0; i < n; i++) {
		lst[numeric] = edge(i + 1, 0, 1, 0);
		g[s].push_back(numeric++);
		lst[numeric] = edge(s, 0, 0, 0);
		g[i + 1].push_back(numeric++);
	}
	for (int i = 0; i < n; i++) {
		a = i + 1; b = i + 1 + n;
		lst[numeric] = edge(b, 0, 1, -arr[i].cost);
		g[a].push_back(numeric++);
		lst[numeric] = edge(a, 0, 0, arr[i].cost);
		g[b].push_back(numeric++);
	}
	sort(arr.begin(), arr.end());
	for (int i = 0; i < n; i++) {
		a = arr[i].num + 1;
		if (i < n - 1) {
			b = arr[i + 1].num + 1;
		} else {
			b = t;
		}
		lst[numeric] = edge(b, 0, 1, 0);
		g[a].push_back(numeric++);
		lst[numeric] = edge(a, 0, 0, 0);
		g[b].push_back(numeric++);
	}
	for (int i = 0; i < n; i++) {
		a = arr[i].num + 1 + n;
		int ptr = lower_bound(arr.begin(), arr.end(), task(arr[i].l + arr[i].t, 0, 0, -1)) - arr.begin();
		if (ptr < (int)arr.size()) {
			b = arr[ptr].num + 1;
		} else {
			b = t;
		}
		lst[numeric] = edge(b, 0, 1, 0);
		g[a].push_back(numeric++);
		lst[numeric] = edge(a, 0, 0, 0);
		g[b].push_back(numeric++);
	}

	lst[numeric] = edge(t + 1, 0, k, 0);
	g[t].push_back(numeric++);
	lst[numeric] = edge(t, 0, 0, 0);
	g[t + 1].push_back(numeric++);
	t++;
	lst.resize(numeric);

	while (push_flow()) {}

	vector <int> ans(n);
	for (int i = n + 1; i <= 2 * n; i++) {
		for (int j = 0; j < (int)g[i].size(); j++) {
			int num = g[i][j];
			if (lst[num].f == 1) {
				ans[i - n - 1] = 1;
			}
		}
	}

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

	return 0;
}


#include <iostream>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <bitset>
#include <ctime>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#pragma comment(linker, "/STACK:256000000")
using namespace std;

#define in(s) freopen(s, "r", stdin)
#define out(s) freopen(s, "w", stdout)
#define forn(i, n) for (int i = 0; i < n; i++)
#define endl '\n'
#define mp make_pair

typedef long long ll;
typedef long double ld;

const int inf = (int)1e+9 + 7;

struct edge {
	int to, f, c, cost;

	edge() = default;

	edge(int nt, int fn, int cn, int ccn) {
		to = nt;
		f = fn;
		c = cn;
		cost = ccn;
	}
};

int s, t;
vector < vector<int> > g;
vector <int> f;
vector <edge> lst;

bool push_flow() {
	static int iter = -1;
	iter++;
	vector <int> d(g.size(), inf);
	vector < pair<int, int> > par(g.size(), make_pair(-1, -1));
	d[s] = 0;

	if (!iter) {
		for (int t = 0; t < (int)g.size(); t++) {
			bool any = false;
			for (int i = 0; i < (int)g.size(); i++) {
				if (d[i] == inf)
					continue;
				for (int j = 0; j < (int)g[i].size(); j++) {
					int num = g[i][j];
					if (lst[num].f == lst[num].c)
						continue;
					if (d[lst[num].to] > d[i] + lst[num].cost) {
						any = true;
						d[lst[num].to] = d[i] + lst[num].cost;
						par[lst[num].to] = make_pair(i, num);
					}
				}
			}
			if (!any)
				break;
		}
	} else {
		vector <bool> inq(d.size());
		for (int i = 0; i < (int)d.size(); i++) {
			int minu = inf, v = -1;
			for (int j = 0; j < (int)d.size(); j++) {
				if (!inq[j] && d[j] < minu) {
					minu = d[j];
					v = j;
				}
			}
			if (v == -1)
				break;
			inq[v] = true;
			for (int j = 0; j < (int)g[v].size(); j++) {
				int num = g[v][j];
				if (lst[num].f == lst[num].c)
					continue;
				if (d[lst[num].to] > d[v] + lst[num].cost + f[v] - f[lst[num].to]) {
					d[lst[num].to] = d[v] + lst[num].cost + f[v] - f[lst[num].to];
					par[lst[num].to] = make_pair(v, num);
				}
			}
		}
	}
	for (int i = 0; i < (int)f.size(); i++)
		f[i] += d[i];

	int add = inf;
	pair <int, int> cur = make_pair(t, -1);
	vector <int> path;
	while (true) {
		if (cur.second != -1) {
			path.push_back(cur.second);
			add = min(add, lst[cur.second].c - lst[cur.second].f);
		}
		if (par[cur.first].first == -1)
			break;
		cur = par[cur.first];
	}
	for (int i = 0; i < (int)path.size(); i++) {
		lst[path[i]].f += add;
		lst[path[i] ^ 1].f -= add;
	}
	return (!path.empty());
}

vector<int> gm;
vector <int> ans;
int cur_rob = 0;

void dfs(int v) {
	ans[v] = cur_rob;
	if (gm[v] != -1)
		dfs(gm[v]);
}

struct task {
	int l, t, cost, num;

	task() = default;

	task(int nl, int nt, int nc, int nn) {
		l = nl;
		t = nt;
		cost = nc;
		num = nn;
	}

	bool operator<(const task& b) {
		if (l != b.l)
			return l < b.l;
		else
			return num < b.num;
	}
};

int main()
{
	//in("input.txt");
	//out("output.txt");
	srand(1373737);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	int n, k, a, b, numeric = 0;
	cin >> n >> k;

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

	vector <task> arr(n);
	for (int i = 0; i < n; i++) {
		cin >> arr[i].l >> arr[i].t >> arr[i].cost;
		arr[i].num = i;
	}

	g.resize(2 * n + 3);
	f.resize(2 * n + 3);
	lst.resize(2 * (n * n + 2 * n + 1));

	for (int i = 0; i < n; i++) {
		lst[numeric] = edge(i + 1, 0, 1, 0);
		g[s].push_back(numeric++);
		lst[numeric] = edge(s, 0, 0, 0);
		g[i + 1].push_back(numeric++);
	}
	for (int i = 0; i < n; i++) {
		a = i + 1; b = i + 1 + n;
		lst[numeric] = edge(b, 0, 1, -arr[i].cost);
		g[a].push_back(numeric++);
		lst[numeric] = edge(a, 0, 0, arr[i].cost);
		g[b].push_back(numeric++);
	}
	sort(arr.begin(), arr.end());
	for (int i = 0; i < n - 1; i++) {
		a = arr[i].num + 1; b = arr[i + 1].num + 1;
		lst[numeric] = edge(b, 0, 1, 0);
		g[a].push_back(numeric++);
		lst[numeric] = edge(a, 0, 0, 0);
		g[b].push_back(numeric++);
	}
	for (int i = 0; i < n; i++) {
		a = arr[i].num + 1 + n;
		int ptr = lower_bound(arr.begin(), arr.end(), task(arr[i].l + arr[i].t, 0, 0, -1)) - arr.begin();
		if (ptr == (int)arr.size())
			continue;
		b = arr[ptr].num + 1;
		lst[numeric] = edge(b, 0, 1, 0);
		g[a].push_back(numeric++);
		lst[numeric] = edge(a, 0, 0, 0);
		g[b].push_back(numeric++);
	}
	for (int i = 0; i < n; i++) {
		lst[numeric] = edge(t, 0, 1, 0);
		g[i + 1 + n].push_back(numeric++);
		lst[numeric] = edge(i + 1 + n, 0, 0, 0);
		g[t].push_back(numeric++);
	}

	lst[numeric] = edge(t + 1, 0, k, 0);
	g[t].push_back(numeric++);
	lst[numeric] = edge(t, 0, 0, 0);
	g[t + 1].push_back(numeric++);
	t++;
	lst.resize(numeric);

	while (push_flow()) {}

	ans.resize(n, -1);
	gm.resize(n, -1);
	vector <int> degin(n);
	vector <bool> cover(n);
	for (int i = n + 1; i <= 2 * n; i++) {
		for (int j = 0; j < (int)g[i].size(); j++) {
			int num = g[i][j];
			if (lst[num].f == 1) {
				cover[i - n - 1] = true;
				if (lst[num].to != t - 1) {
					gm[i - n - 1] = lst[num].to - 1;
					degin[gm[i - n - 1]]++;
				}
			}
		}
	}

	for (int i = 0; i < n; i++) {
		if (degin[i] == 0 && cover[i]) {
			dfs(i);
			cur_rob++;
		}
	}

	for (int i = 0; i < n; i++)
		cout << (int)(ans[i] > -1) << " ";

	return 0;
}


/*
** Vishal Raj Roy
** Indian Institute of Technology Kharagpur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define xx first
#define yy second
#define sz(x) ((int)x.size())
#define nl cout << "\n";
#define li long long int
#define u64 uint64_t
#define u128 __uint128_t
#define db double
#define ld long double
#define fo(i, l, r) for (int i = l - (l > r); i != r - (l > r); i += 1 - 2 * (l > r))
#define se(X, C) for (auto& X : C)
#define ima INT_MAX
#define imi INT_MIN
#define lma LLONG_MAX
#define lmi LLONG_MIN
#define mem(X, A) memset(X, A, sizeof(X))
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define name(X) (#X)
#define re(...)             __VA_ARGS__; tk(__VA_ARGS__)
#define rl(name, ...)  name(__VA_ARGS__); cin >> name
#define tl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); tell(_it, args); }

template <class ...As> auto &tk(As &...as) { return (cin >> ... >> as); } template <class T> auto &operator>>(istream &is, vector<T> &V) { for (auto &x : V) is >> x; return is; } template <class L, class R> auto &operator>>(istream& is, pair<L, R>& P) { return is >> P.first >> P.second; } template <class T> struct custom_hash { static uint64_t splitmix64(uint64_t x) { x += 0x9e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31); } T operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);} T operator()(tuple<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(get<0>(x) + FIXED_RANDOM)^(splitmix64(get<1>(x) + FIXED_RANDOM) >> 1); } }; void tell(istream_iterator<string> it) {} template<typename T, typename... Args> void tell(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; tell(++it, args...);} template <class L, class R> ostream & operator<<(ostream &os, pair<L,R> P) { return os << "(" << P.xx << "," << P.yy << ")"; } template<class L, class R> ostream &operator<<(ostream &os, tuple<L,R> P) {return os << "(" << get<0>(P) << "," << get<1>(P) <<")"; } template<class L, class R, class S> ostream &operator<<(ostream &os, tuple<L,R,S> P) { return os << "(" << get<0>(P) << "," << get<1>(P) << ","<< get<2>(P) <<")"; } template<class T, class A> ostream &operator<<(ostream& os, vector<T,A> V) {os /*<< name(V)<< " is "*/ << "\n"; fo(i,0,sz(V)) os <<"  "<< name(V) << "["<<i<<"] = "<< V[i] << "\n"; return os; /*<<"\n";*/ } template<class T, class H, class P, class A> ostream &operator<<(ostream& os, unordered_set<T,H,P,A> S) { os /*name(S) << " is"*/<<" ["; int i = 0; for(auto ELE : S) {os << ELE; if(i < sz(S)-1 ) os<<", "; i++; } return os <<  "]"; /*<<"\n"; */ } template<class S, class T, class H, class P, class A> ostream &operator<<(ostream& os, unordered_map<S,T,H,P,A> M) { os /*name(S) << " is"*/<<"\n"; for( auto ELE : M ) os <<"  "<< name(M) << "["<<ELE.xx<<"] = "<< ELE.yy << "\n"; return os; /*<<"\n";*/ } template<class T, class C, class A> ostream &operator<<(ostream& os, multiset<T,C,A> S) { os /*name(S) << " is"*/<<"["; int i = 0; for(auto ELE : S) {os << ELE; if(i < sz(S)-1 ) os<<", "; i++; } return os <<  "]"; /*<<"\n"; */ } template<class T, class R> ostream &operator<<(ostream& os, gp_hash_table<T,null_type,custom_hash<R>> S) { os /*name(S) << " is"*/<<" ["; int i = 0; for(auto ELE : S) {os << ELE; if(i < sz(S)-1 ) os<<", "; i++; } return os <<  "]"; /*<<"\n"; */ } template<class T, class Z, class R> ostream &operator<<(ostream& os, gp_hash_table<T,Z,custom_hash<R>> M) { os /*name(S) << " is"*/<<"\n"; for( auto ELE : M ) os <<"  "<< name(M) << "["<<ELE.xx<<"] = "<< ELE.yy << "\n"; return os; /*<<"\n";*/ } template<class T, class R> ostream &operator<<(ostream& os, cc_hash_table<T,null_type,custom_hash<R>> S) { os /*name(S) << " is"*/<<" ["; int i = 0; for(auto ELE : S) {os << ELE; if(i < sz(S)-1 ) os<<", "; i++; } return os <<  "]"; /*<<"\n"; */ } template<class T, class Z, class R> ostream &operator<<(ostream& os, cc_hash_table<T,Z,custom_hash<R>> M) { os /*name(S) << " is"*/<<"\n"; for( auto ELE : M ) os <<"  "<< name(M) << "["<<ELE.xx<<"] = "<< ELE.yy << "\n"; return os; /*<<"\n";*/ } using st = string; typedef pair<int, int> ii; typedef pair<int, ii> iii; typedef vector<int> vi; typedef vector<ii> vii; typedef vector<vi> vvi; typedef pair<li, li> ll; typedef vector<li> vl; typedef vector<ll> vll; typedef vector<vl> vvl; template <class S> using ve = vector<S>; template <class S, class T = null_type, class R = size_t> using gp = gp_hash_table<S, T, custom_hash<R> >; template <class S, class T = null_type, class R = size_t> using cc = cc_hash_table<S, T, custom_hash<R> >; template <class S, class T, class R = size_t> using um = unordered_map<S, T, custom_hash<R> >; template <class S, class R = size_t> using us = unordered_set<S, custom_hash<R> >; /* Keywords --> break continue order_of_key find_by_order goto here true bitset priority_queue deque stack queue insert top push pop front __builtin_popcount __builtin_popcountll back pop_back push_front pop_front greater less erase find count end begin emplace_back merge iota true false set optional empty gcd lcm merge lambda function binary_search for_each rbegin rend constexpr assign clear */
template<class Flow = li, class Cost = li>
struct MCMF {
    const Flow INF_FLOW = 1000111000;
    const Cost INF_COST = 1000111000111000LL;

    int n, t, S, T;
    Flow totalFlow;
    Cost totalCost;
    vector<int> last, visited;
    vector<Cost> dis;
    struct Edge {
        int to;
        Flow cap;
        Cost cost;
        int next;
        Edge(int to, Flow cap, Cost cost, int next) :
                to(to), cap(cap), cost(cost), next(next) {}
    };
    vector<Edge> edges;

    MCMF(int n) : n(n), t(0), totalFlow(0), totalCost(0), last(n, -1), visited(n, 0), dis(n, 0) {
        edges.clear();
    }

    int addEdge(int from, int to, Flow cap, Cost cost) {
        edges.push_back(Edge(to, cap, cost, last[from]));
        last[from] = t++;
        edges.push_back(Edge(from, 0, -cost, last[to]));
        last[to] = t++;
        return t - 2;
    }

    pair<Flow, Cost> calc(int _S, int _T) {
        S = _S; T = _T;
        SPFA();
        while (1) {
            while (1) {
                fo(i,0,n) visited[i] = 0;
                if (!findFlow(S, INF_FLOW)) break;
            }
            if (!modifyLabel()) break;
        }
        return make_pair(totalFlow, totalCost);
    }

    void find( int u, vi & ans ) {
        return;
    }

private:
    void SPFA() {
        fo(i,0,n) dis[i] = INF_COST;
        priority_queue< pair<Cost,int> > Q;
        Q.push(make_pair(dis[S]=0, S));
        while (!Q.empty()) {
            int x = Q.top().second;
            Cost d = -Q.top().first;
            Q.pop();
            // For double: dis[x] > d + EPS
            if (dis[x] != d) continue;
            for(int it = last[x]; it >= 0; it = edges[it].next)
                if (edges[it].cap > 0 && dis[edges[it].to] > d + edges[it].cost)
                    Q.push(make_pair(-(dis[edges[it].to] = d + edges[it].cost), edges[it].to));
        }
        Cost disT = dis[T]; fo(i,0,n) dis[i] = disT - dis[i];
    }

    Flow findFlow(int x, Flow flow) {
        if (x == T) {
            totalCost += dis[S] * flow;
            totalFlow += flow;
            return flow;
        }
        visited[x] = 1;
        Flow now = flow;
        for(int it = last[x]; it >= 0; it = edges[it].next)
            // For double: fabs(dis[edges[it].to] + edges[it].cost - dis[x]) < EPS
            if (edges[it].cap && !visited[edges[it].to] && dis[edges[it].to] + edges[it].cost == dis[x]) {
                Flow tmp = findFlow(edges[it].to, min(now, edges[it].cap));
                edges[it].cap -= tmp;
                edges[it ^ 1].cap += tmp;
                now -= tmp;
                if (!now) break;
            }
        return flow - now;
    }

    bool modifyLabel() {
        Cost d = INF_COST;
        fo(i,0,n) if (visited[i])
            for(int it = last[i]; it >= 0; it = edges[it].next)
                if (edges[it].cap && !visited[edges[it].to])
                    d = min(d, dis[edges[it].to] + edges[it].cost - dis[i]);

        // For double: if (d > INF_COST / 10)     INF_COST = 1e20
        if (d == INF_COST) return false;
        fo(i,0,n) if (visited[i])
            dis[i] += d;
        return true;
    }
};
/*
    MCMF Flow(num nodes); Flow.addEdge(u,v,w,c); Flow.calc(s,t);
*/
li S[1005], E[1005], C[1005];
int XX[1005];
bool comp( int i, int j ) {
    return S[i] < S[j];
}
void solve(int test) {
    int re(n,k);
    fo(i,0,n) {
        tk(S[i],E[i],C[i]);
        E[i] = E[i]+S[i]-1;
    }
    S[n] = E[n] = 1e10;
    vi v(n,0); fo(i,0,n) v[i] = i;
    sort(all(v),comp);
    v.pb(n);
    MCMF Flow(n+3);
    fo(i,1,n+1) Flow.addEdge(i,i+1,k,0);
    Flow.addEdge(0,1,k,0);
    Flow.addEdge(n+1,n+2,k,0);
    vi eid;
    fo(i,0,n) {
        int j = i;
        while( S[v[j]] <= E[v[i]] ) j++;
        eid.pb(Flow.edges.size());
        Flow.addEdge(i+1,j+1,1,-1*C[v[i]]);
    }
    Flow.calc(0,n+2);
    // vi ans;
    // Flow.find(0,ans);
    // se(e,ans) XX[v[e]] = 1;
    fo(i,0,sz(eid)) {
        int e = eid[i];
        auto & ee = Flow.edges[e];
        // tl(ee.cap,ee.to);
        if( !ee.cap ) XX[v[i]] = 1;
    }
    fo(i,0,n) cout<<XX[i]<<" "; cout<<"\n";
}

int main() {
    fast; int Test = 1;
    // cin >> Test;
    fo(i,1,Test+1) solve(i);
    return 0;
}


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

struct Edge {
    int from, to, cost, capacity;
    Edge(int from=-1, int to=-1, int cost=0, int capacity=0)
        : from(from), to(to), cost(cost), capacity(capacity) {
    }
};

std::pair<bool, std::vector<int>> BellmanFord(std::vector<Edge> const& edges, int s, int n) {
    int INF = std::numeric_limits<int>::max();
    std::vector<int> d(n, INF);
    d[s] = 0;

    bool improved = true;
    for (int i = 0; i < n && improved; ++i) {
        improved = false;
        for (Edge const& e : edges) {
            if (e.capacity > 0 && d[e.from] < INF && d[e.from] + e.cost < d[e.to]) {
                d[e.to] = d[e.from] + e.cost;
                improved = true;
            }
        }
    }
    return {improved, d};  // true if negative cycle
}

class MinCostMaxFlow {
public:
    std::pair<int, int> solve(std::vector<Edge> const& edges, int source, int sink, int n) {
        int m = (int)edges.size();
        directed_edges.resize(2 * m);
        adj.resize(n);
        for (int i = 0; i < m; i++) {
            Edge e = edges[i];
            directed_edges[2*i] = e;
            directed_edges[2*i+1] = Edge(e.to, e.from, -e.cost, 0);
            adj[e.from].push_back(2*i);
            adj[e.to].push_back(2*i+1);
        }

        auto [negative_cycle, distances] = BellmanFord(directed_edges, source, n);
        assert(!negative_cycle);
        potential = distances;

        int flow = 0;
        int total_cost = 0;
        while (true) {
            auto [distances, prev_edge] = dijkstra(source);
            if (prev_edge[sink] == -1)
                break;

            // fix potentials
            for (int i = 0; i < n; i++) {
                if (distances[i] < std::numeric_limits<int>::max())
                    potential[i] += distances[i];
            }

            // augment path
            int cur_flow = std::numeric_limits<int>::max();
            int cur = sink;
            while (cur != source) {
                int prev_edge_idx = prev_edge[cur];
                Edge& prev_edge = directed_edges[prev_edge_idx];
                cur_flow = std::min(cur_flow, prev_edge.capacity);
                cur = prev_edge.from;
            }
            cur = sink;
            flow += cur_flow;
            while (cur != source) {
                int prev_edge_idx = prev_edge[cur];
                Edge& prev_edge = directed_edges[prev_edge_idx];
                Edge& prev_edge_rev = directed_edges[prev_edge_idx ^ 1];
                total_cost += cur_flow * prev_edge.cost;
                prev_edge.capacity -= cur_flow;
                prev_edge_rev.capacity += cur_flow;
                cur = prev_edge.from;
            }
        }

        return {flow, total_cost};
    }

    std::pair<std::vector<int>, std::vector<int>> dijkstra(int v0) {
        int n = adj.size();
        int INF = std::numeric_limits<int>::max();
        std::vector<int> distance(n, INF), prev_edge(n, -1);
        std::priority_queue<std::pair<int, int>> pq;
        pq.push({0, v0});
        distance[v0] = 0;
        while (!pq.empty()) {
            auto x = pq.top();
            pq.pop();
            long long dist = -x.first;
            int v = x.second;
            if (dist > distance[v])
                continue;
            for (auto e_idx : adj[v]) {
                Edge& e = directed_edges[e_idx];
                if (e.capacity == 0)
                    continue;
                int new_cost = e.cost + potential[v]- potential[e.to];
                if (dist + new_cost < distance[e.to]) {
                    distance[e.to] = dist + new_cost;
                    prev_edge[e.to] = e_idx;
                    pq.push({-distance[e.to], e.to});
                }
            }
        }
        return {distance, prev_edge};
    }

    std::vector<int> potential;
    std::vector<std::vector<int>> adj;
    std::vector<Edge> directed_edges;
};

struct E {
    int s, e, c;
};

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

    int n, k;
    cin >> n >> k;

    vector<E> v(n);
    vector<int> starts(n + 2);
    for (int i = 0; i < n; i++) {
        int s, t, c;
        cin >> s >> t >> c;
        v[i] = {s, s + t, c};
        starts[i] = s;
    }
    starts[n] = 0;
    starts[n+1] = std::numeric_limits<int>::max();
    sort(starts.begin(), starts.end());
    auto it = unique(starts.begin(), starts.end());
    starts.resize(it - starts.begin());

    vector<Edge> edges;
    for (auto edge : v) {
        int s = lower_bound(starts.begin(), starts.end(), edge.s) - starts.begin();
        int e = lower_bound(starts.begin(), starts.end(), edge.e) - starts.begin();
        edges.emplace_back(s, e, -edge.c, 1);
    }
    for (int i = 0; i + 1 < (int)starts.size(); i++) {
        edges.emplace_back(i, i+1, 0, k);
    }

    MinCostMaxFlow mcmf;
    mcmf.solve(edges, 0, starts.size() - 1, starts.size());
    for (int i = 0; i < n; i++) {
        cout << (1 - mcmf.directed_edges[2*i].capacity) << " ";
    }
    cout << endl;
}


#include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

map<int,int> mp;
const int inf=1<<30;
int n,tot,src,sink,cnt,k;
int v[10005],c[10005],w[10005],rev[10005],nxt[10005],h[10005],dis[10005],prec[10005],pree[10005],s[10005],t[10005],d[10005],g[10005];
bool vis[10005];

int addedge(int x,int y,int z,int f){
	v[++tot]=y; c[tot]=z; w[tot]=f; rev[tot]=tot+1; nxt[tot]=h[x]; h[x]=tot;
	v[++tot]=x; c[tot]=0; w[tot]=-f; rev[tot]=tot-1; nxt[tot]=h[y]; h[y]=tot;
	return tot-1;
}

bool spfa(){
	for(int i=src;i<=sink;i++) dis[i]=inf;
	memset(vis,false,sizeof(vis));
	queue<int> q;
	dis[src]=0,vis[src]=true; q.push(src);
	while(!q.empty()){
		int t=q.front(); q.pop();
		vis[t]=false;
		for(int p=h[t];p;p=nxt[p]){
			if(c[p]>0&&dis[v[p]]>dis[t]+w[p]){
				dis[v[p]]=dis[t]+w[p];
				prec[v[p]]=t,pree[v[p]]=p;
				if(!vis[v[p]]){
					vis[v[p]]=true;
					q.push(v[p]);
				}
			}
		}
	}
	if(dis[sink]<inf) return true;
	return false;
}

int augment(){
	int flow=inf;
	for(int u=sink;u!=src;u=prec[u]) flow=min(flow,c[pree[u]]);
	for(int u=sink;u!=src;u=prec[u]){
		c[pree[u]]-=flow;
		c[rev[pree[u]]]+=flow;
	}
	return flow;
}

int main(){
	n=readint(); k=readint();
	for(int i=1;i<=n;i++){
		s[i]=readint(); t[i]=readint(); d[i]=readint();
		t[i]=s[i]+t[i]-1;
		mp[s[i]]=1,mp[t[i]+1]=1;
	}
	for(map<int,int>::iterator it=mp.begin();it!=mp.end();it++) it->second=++cnt;
	src=0,sink=cnt+1;
	for(int i=1;i<=cnt-1;i++) addedge(i,i+1,k,0);
	addedge(src,1,k,0); addedge(cnt,sink,k,0);
	for(int i=1;i<=n;i++) g[i]=addedge(mp[s[i]],mp[t[i]+1],1,-d[i]);
	while(spfa()) augment();
	for(int i=1;i<=n;i++) printf("%d ",c[rev[g[i]]]);
	printf("\n");
	return 0;
}


#include<bits/stdc++.h>
/*---------------------Define--------------------*/
#define next nextt
#define pii pair<int,int>
#define fi first
#define se second
#define rd random
#define ll long long
#define taskname ""
#define pb push_back
#define mp make_pair
#define pb push_back
#define popb pop_back
#define popf pop_front
#define pf push_front
#define res(a,z,n) for(int i = 1 ; i<=n ; i ++) a[i] = z;
/*-------------------necesary---------------------*/
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*------------------limit-------------------------*/
const int base  = 1e9+7;
const int oo = 2003;
const int inf  = INT_MAX;
/*-----------------globalvari-----------------------*/
int n,m,k,q;
int maxf,s,t,S;
vector<int> a[oo];
int cap[oo*oo];
int f[oo*oo];
int cost[oo*oo];
int val[oo*oo];
int st[oo],en[oo];
int ans[oo];
int costt[oo];

int stt[oo][oo];
int N;
vector<int> adj[oo];
pii p[oo];
/*-----------------code-----------------------*/

void input()
{
    cin>>n>>m;
    int x;
    for(int i=1;i<=n;i++)
    {
        cin>>st[i]>>x>>costt[i];
        en[i] = st[i] + x;
    }
}

void compress(vector<int> &a)
{
    int n = a.size();
    set<int> s(a.begin(),a.end());
    vector<int> b(s.begin(),s.end());
    for(int i=0;i<n;i++)
        a[i] = upper_bound(b.begin(),b.end(),a[i]) - b.begin();
}

void khoitao(int x,int y,int c,int z,int i)
{
 //   cerr<<x<<" "<<y<<" "<<c<<" "<<z<<" "<<i<<endl;
    adj[x].pb(i);
    adj[y].pb(i^1);
    p[i] = mp(x,y);
    cost[i] = c;
    val[i] = y;
    cost[i^1] = -c;
    cap[i] = z;
    val[i^1] = x;
}

void cre()
{
    vector<int> pos;
    for(int i=1;i<=n;i++)
    {
        pos.pb(st[i]);
        pos.pb(en[i]);
    }
    compress(pos);
    N = pos.size();
    N*=2;
    int cur = 0;
    for(int i=1;i<=n;i++)
    {
        st[i] = pos[cur++]*2 ;
        en[i] = pos[cur++]*2 ;
    }

    cur = 0;

    for(int i=1;i<=n;i++)
    {
        stt[st[i]][en[i]] = i;
        khoitao(st[i],en[i],-costt[i],1,cur);
        cur += 2;
    }

    s = 0;
    t = N + 2;

    for(int i = 0 ; i < N+2 ; i ++)
    {
        khoitao(i,i+1,0,m,cur);
        cur+=2;
    }

}

int inq[oo];
int tr[oo];
int d[oo];

bool fp()
{
    queue<int> q;
    for(int i=1;i<=t;i++)
    {
        inq[i] = 0;
        tr[i] = 0;
        d[i] = inf;
    }
    q.push(s);
    inq[s] = 0;
    d[s] = 0;
    while(!q.empty())
    {
        //cerr<<u<<endl;
        int u = q.front();

        //cerr<<u<<" "<<d[t]<<endl;
        q.pop();
        inq[u] = 0;
        for(int i = 0 ; i < adj[u].size() ; i ++)
        {
            int v = adj[u][i];
            if(cap[v] > f[v])
            {
                int uv = cost[v];
                // uv = -uv;
                int TT = val[v];
                if(d[TT] > d[u] + uv)
                {
                    tr[TT] = v;
                    d[TT] = d[u] + uv;
                    if(inq[TT] == 0)
                    {
                        inq[TT] = 1;
                        q.push(TT);
                    }
                }
            }
        }
    }

    return tr[t];
}

int minc ;

void IncFlow()
{
    int D = inf;
    for(int i = t ; i!=s  ;  )
    {
        int u = tr[i];
    //    cerr<<i<<" ";
        D = min(D,cap[u] - f[u]);
        i = val[u^1];
    }
    //cerr<<endl;
    //cerr<<D<<endl;
    for(int i = t ; i!=s ; )
    {
        int u = tr[i];
        f[u] += D;
        f[u^1] -= D;
        i = val[u^1];
    }

    //cerr<<D<<endl;

    minc += D*d[t];
    maxf += D;
}

void solve()
{
    cre();
    while(fp()) IncFlow();
   // if(maxf < S) {cout<<-1;return ;}
    //cout<<minc<<"\n";
    int tmp = 0;
    for(int i=1;i<=n;i++)
    {
        if(f[tmp]) cout<<1<<" ";
        else cout<<0<<" ";
        tmp+=2;
    }
    //main code here :))
}
void ouput()
{
    //int ns = n + 1 ;

    //a[ns].pb(s);

    //write
}

int32_t main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //#ifndef ONLINE_JUDGES
    if (ifstream("test.txt"))
    {
        freopen("test.txt", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            //\freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
    //#endif // ONLINE_JUDGES
    int t=1;
   // cin>>t;

    while(t--)
    {
    input();
    solve();
    ouput();
    }
}

//ilove??<3


#include<bits/stdc++.h>
/*---------------------Define--------------------*/
#define next nextt
#define pii pair<int,int>
#define fi first
#define se second
#define rd random
#define ll long long
#define taskname ""
#define pb push_back
#define mp make_pair
#define pb push_back
#define popb pop_back
#define popf pop_front
#define pf push_front
#define res(a,z,n) for(int i = 1 ; i<=n ; i ++) a[i] = z;
/*-------------------necesary---------------------*/
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*------------------limit-------------------------*/
const int base  = 1e9+7;
const int oo = 4003;
const int inf  = INT_MAX;
/*-----------------globalvari-----------------------*/
int n,m,k,q;
int maxf,s,t,S;
vector<int> a[oo];
int cap[oo*oo];
int f[oo*oo];
int cost[oo*oo];
int val[oo*oo];
int st[oo],en[oo];
int ans[oo];
int costt[oo];
int stt[oo][oo];
int N;
vector<int> adj[oo];
pii p[oo];
/*-----------------code-----------------------*/

void input()
{
    cin>>n>>m;
    int x;
    for(int i=1;i<=n;i++)
    {
        cin>>st[i]>>x>>costt[i];
        en[i] = st[i] + x;
    }
}

void compress(vector<int> &a)
{
    int n = a.size();
    set<int> s(a.begin(),a.end());
    vector<int> b(s.begin(),s.end());
    for(int i=0;i<n;i++)
        a[i] = upper_bound(b.begin(),b.end(),a[i]) - b.begin();
}

void khoitao(int x,int y,int c,int z,int i)
{
 //   cerr<<x<<" "<<y<<" "<<c<<" "<<z<<" "<<i<<endl;
    adj[x].pb(i);
    adj[y].pb(i^1);
    p[i] = mp(x,y);
    cost[i] = c;
    val[i] = y;
    cost[i^1] = -c;
    cap[i] = z;
    val[i^1] = x;
}

void cre()
{
    vector<int> pos;
    for(int i=1;i<=n;i++)
    {
        pos.pb(st[i]);
        pos.pb(en[i]);
    }
    compress(pos);
    N = pos.size();
    N*=2;
    int cur = 0;
    for(int i=1;i<=n;i++)
    {
        st[i] = pos[cur++]*2 ;
        en[i] = pos[cur++]*2 ;
    }

    cur = 0;

    for(int i=1;i<=n;i++)
    {
        stt[st[i]][en[i]] = i;
        khoitao(st[i],en[i],-costt[i],1,cur);
        cur += 2;
    }

    s = 0;
    t = N + 2;

    for(int i = 0 ; i < N+2 ; i ++)
    {
        khoitao(i,i+1,0,m,cur);
        cur+=2;
    }

}

int inq[oo];
int tr[oo];
int d[oo];

bool fp()
{
    queue<int> q;
    for(int i=1;i<=t;i++)
    {
        inq[i] = 0;
        tr[i] = 0;
        d[i] = inf;
    }
    q.push(s);
    inq[s] = 0;
    d[s] = 0;
    while(!q.empty())
    {
        //cerr<<u<<endl;
        int u = q.front();

        //cerr<<u<<" "<<d[t]<<endl;
        q.pop();
        inq[u] = 0;
        for(int i = 0 ; i < adj[u].size() ; i ++)
        {
            int v = adj[u][i];
            if(cap[v] > f[v])
            {
                int uv = cost[v];
                // uv = -uv;
                int TT = val[v];
                if(d[TT] > d[u] + uv)
                {
                    tr[TT] = v;
                    d[TT] = d[u] + uv;
                    if(inq[TT] == 0)
                    {
                        inq[TT] = 1;
                        q.push(TT);
                    }
                }
            }
        }
    }

    return tr[t];
}

int minc ;

void IncFlow()
{
    int D = inf;
    for(int i = t ; i!=s  ;  )
    {
        int u = tr[i];
    //    cerr<<i<<" ";
        D = min(D,cap[u] - f[u]);
        i = val[u^1];
    }
    //cerr<<endl;
    //cerr<<D<<endl;
    for(int i = t ; i!=s ; )
    {
        int u = tr[i];
        f[u] += D;
        f[u^1] -= D;
        i = val[u^1];
    }

    //cerr<<D<<endl;

    minc += D*d[t];
    maxf += D;
}

void solve()
{
    cre();
    while(fp()) IncFlow();
   // if(maxf < S) {cout<<-1;return ;}
    //cout<<minc<<"\n";
    int tmp = 0;
    for(int i=1;i<=n;i++)
    {
        if(f[tmp]) cout<<1<<" ";
        else cout<<0<<" ";
        tmp+=2;
    }
    //main code here :))
}
void ouput()
{
    //int ns = n + 1 ;

    //a[ns].pb(s);

    //write
}

int32_t main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //#ifndef ONLINE_JUDGES
    if (ifstream("test.txt"))
    {
        freopen("test.txt", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            //\freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
    //#endif // ONLINE_JUDGES
    int t=1;
   // cin>>t;

    while(t--)
    {
    input();
    solve();
    ouput();
    }
}

//ilove??<3


#include<bits/stdc++.h>
/*---------------------Define--------------------*/
#define next nextt
#define pii pair<int,int>
#define fi first
#define se second
#define rd random
#define ll long long
#define taskname ""
#define pb push_back
#define mp make_pair
#define pb push_back
#define popb pop_back
#define popf pop_front
#define pf push_front
#define res(a,z,n) for(int i = 1 ; i<=n ; i ++) a[i] = z;
/*-------------------necesary---------------------*/
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*------------------limit-------------------------*/
const int base  = 1e9+7;
const int oo = 4003;
const int inf  = INT_MAX;
/*-----------------globalvari-----------------------*/

int n,m,k,q;
int maxf,s,t,S;
vector<int> a[oo];
int cap[oo*4];
int f[oo*4];
int cost[oo*4];
int val[oo*4];
int st[oo],en[oo];
int ans[oo];
int costt[oo];

int N;
vector<int> adj[oo];
//pii p[oo];
/*-----------------code-----------------------*/

void input()
{
    cin>>n>>m;
    int x;
    for(int i=1;i<=n;i++)
    {
        cin>>st[i]>>x>>costt[i];
        en[i] = st[i] + x;
    }
}

void compress(vector<int> &a)
{
    int n = a.size();
    set<int> s(a.begin(),a.end());
    vector<int> b(s.begin(),s.end());
    for(int i=0;i<n;i++)
        a[i] = upper_bound(b.begin(),b.end(),a[i]) - b.begin();
}

void khoitao(int x,int y,int c,int z,int i)
{
 //   cerr<<x<<" "<<y<<" "<<c<<" "<<z<<" "<<i<<endl;
    adj[x].pb(i);
    adj[y].pb(i^1);
   // p[i] = mp(x,y);
    cost[i] = c;
    val[i] = y;
    cost[i^1] = -c;
    cap[i] = z;
    val[i^1] = x;
}

void cre()
{
    vector<int> pos;
    for(int i=1;i<=n;i++)
    {
        pos.pb(st[i]);
        pos.pb(en[i]);
    }
    compress(pos);
    N = pos.size();
    N*=2;
    int cur = 0;
    for(int i=1;i<=n;i++)
    {
        st[i] = pos[cur++]*2 ;
        en[i] = pos[cur++]*2 ;
    }

    cur = 0;

    for(int i=1;i<=n;i++)
    {
        //stt[st[i]][en[i]] = i;
        khoitao(st[i],en[i],-costt[i],1,cur);
        cur += 2;
    }

    s = 0;
    t = N + 2;

    for(int i = 0 ; i < N+2 ; i ++)
    {
        khoitao(i,i+1,0,m,cur);
        cur+=2;
    }

}

int inq[oo];
int tr[oo];
int d[oo];

bool fp()
{
    queue<int> q;
    for(int i=1;i<=t;i++)
    {
        inq[i] = 0;
        tr[i] = 0;
        d[i] = inf;
    }
    q.push(s);
    inq[s] = 0;
    d[s] = 0;
    while(!q.empty())
    {
        //cerr<<u<<endl;
        int u = q.front();

        //cerr<<u<<" "<<d[t]<<endl;
        q.pop();
        inq[u] = 0;
        for(int i = 0 ; i < adj[u].size() ; i ++)
        {
            int v = adj[u][i];
            if(cap[v] > f[v])
            {
                int uv = cost[v];
                // uv = -uv;
                int TT = val[v];
                if(d[TT] > d[u] + uv)
                {
                    tr[TT] = v;
                    d[TT] = d[u] + uv;
                    if(inq[TT] == 0)
                    {
                        inq[TT] = 1;
                        q.push(TT);
                    }
                }
            }
        }
    }

    return tr[t];
}

int minc ;

void IncFlow()
{
    int D = inf;
    for(int i = t ; i!=s  ;  )
    {
        int u = tr[i];
    //    cerr<<i<<" ";
        D = min(D,cap[u] - f[u]);
        i = val[u^1];
    }
    //cerr<<endl;
    //cerr<<D<<endl;
    for(int i = t ; i!=s ; )
    {
        int u = tr[i];
        f[u] += D;
        f[u^1] -= D;
        i = val[u^1];
    }

    //cerr<<D<<endl;

    minc += D*d[t];
    maxf += D;
}

void solve()
{
    cre();
    while(fp()) IncFlow();
   // if(maxf < S) {cout<<-1;return ;}
    //cout<<minc<<"\n";
    int tmp = 0;
    for(int i=1;i<=n;i++)
    {
        if(f[tmp]) cout<<1<<" ";
        else cout<<0<<" ";
        tmp+=2;
    }
    //main code here :))
}
void ouput()
{
    //int ns = n + 1 ;

    //a[ns].pb(s);

    //write
}

int32_t main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //#ifndef ONLINE_JUDGES
    if (ifstream("test.txt"))
    {
        freopen("test.txt", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            //\freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
    //#endif // ONLINE_JUDGES
    int t=1;
   // cin>>t;

    while(t--)
    {
    input();
    solve();
    ouput();
    }
}

//ilove??<3


#include<bits/stdc++.h>
/*---------------------Define--------------------*/
#define next nextt
#define pii pair<int,int>
#define fi first
#define se second
#define rd random
#define ll long long
#define taskname ""
#define pb push_back
#define mp make_pair
#define pb push_back
#define popb pop_back
#define popf pop_front
#define pf push_front
#define res(a,z,n) for(int i = 1 ; i<=n ; i ++) a[i] = z;
/*-------------------necesary---------------------*/
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*------------------limit-------------------------*/
const int base  = 1e9+7;
const int oo = 4003;
const int inf  = INT_MAX;
/*-----------------globalvari-----------------------*/
int n,m,k,q;
int maxf,s,t,S;
vector<int> a[oo];
int cap[oo*4];
int f[oo*4];
int cost[oo*4];
int val[oo*4];
int st[oo],en[oo];
int ans[oo];
int costt[oo];
//int stt[oo][oo];
int N;
vector<int> adj[oo];
pii p[oo];
/*-----------------code-----------------------*/

void input()
{
    cin>>n>>m;
    int x;
    for(int i=1;i<=n;i++)
    {
        cin>>st[i]>>x>>costt[i];
        en[i] = st[i] + x;
    }
}

void compress(vector<int> &a)
{
    int n = a.size();
    set<int> s(a.begin(),a.end());
    vector<int> b(s.begin(),s.end());
    for(int i=0;i<n;i++)
        a[i] = upper_bound(b.begin(),b.end(),a[i]) - b.begin();
}

void khoitao(int x,int y,int c,int z,int i)
{
 //   cerr<<x<<" "<<y<<" "<<c<<" "<<z<<" "<<i<<endl;
    adj[x].pb(i);
    adj[y].pb(i^1);
    p[i] = mp(x,y);
    cost[i] = c;
    val[i] = y;
    cost[i^1] = -c;
    cap[i] = z;
    val[i^1] = x;
}

void cre()
{
    vector<int> pos;
    for(int i=1;i<=n;i++)
    {
        pos.pb(st[i]);
        pos.pb(en[i]);
    }
    compress(pos);
    N = pos.size();
    N*=2;
    int cur = 0;
    for(int i=1;i<=n;i++)
    {
        st[i] = pos[cur++]*2 ;
        en[i] = pos[cur++]*2 ;
    }

    cur = 0;

    for(int i=1;i<=n;i++)
    {
        //stt[st[i]][en[i]] = i;
        khoitao(st[i],en[i],-costt[i],1,cur);
        cur += 2;
    }

    s = 0;
    t = N + 2;

    for(int i = 0 ; i < N+2 ; i ++)
    {
        khoitao(i,i+1,0,m,cur);
        cur+=2;
    }

}

int inq[oo];
int tr[oo];
int d[oo];

bool fp()
{
    queue<int> q;
    for(int i=1;i<=t;i++)
    {
        inq[i] = 0;
        tr[i] = 0;
        d[i] = inf;
    }
    q.push(s);
    inq[s] = 0;
    d[s] = 0;
    while(!q.empty())
    {
        //cerr<<u<<endl;
        int u = q.front();

        //cerr<<u<<" "<<d[t]<<endl;
        q.pop();
        inq[u] = 0;
        for(int i = 0 ; i < adj[u].size() ; i ++)
        {
            int v = adj[u][i];
            if(cap[v] > f[v])
            {
                int uv = cost[v];
                // uv = -uv;
                int TT = val[v];
                if(d[TT] > d[u] + uv)
                {
                    tr[TT] = v;
                    d[TT] = d[u] + uv;
                    if(inq[TT] == 0)
                    {
                        inq[TT] = 1;
                        q.push(TT);
                    }
                }
            }
        }
    }

    return tr[t];
}

int minc ;

void IncFlow()
{
    int D = inf;
    for(int i = t ; i!=s  ;  )
    {
        int u = tr[i];
    //    cerr<<i<<" ";
        D = min(D,cap[u] - f[u]);
        i = val[u^1];
    }
    //cerr<<endl;
    //cerr<<D<<endl;
    for(int i = t ; i!=s ; )
    {
        int u = tr[i];
        f[u] += D;
        f[u^1] -= D;
        i = val[u^1];
    }

    //cerr<<D<<endl;

    minc += D*d[t];
    maxf += D;
}

void solve()
{
    cre();
    while(fp()) IncFlow();
   // if(maxf < S) {cout<<-1;return ;}
    //cout<<minc<<"\n";
    int tmp = 0;
    for(int i=1;i<=n;i++)
    {
        if(f[tmp]) cout<<1<<" ";
        else cout<<0<<" ";
        tmp+=2;
    }
    //main code here :))
}
void ouput()
{
    //int ns = n + 1 ;

    //a[ns].pb(s);

    //write
}

int32_t main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //#ifndef ONLINE_JUDGES
    if (ifstream("test.txt"))
    {
        freopen("test.txt", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            //\freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
    //#endif // ONLINE_JUDGES
    int t=1;
   // cin>>t;

    while(t--)
    {
    input();
    solve();
    ouput();
    }
}

//ilove??<3


#include<bits/stdc++.h>
/*---------------------Define--------------------*/
#define next nextt
#define pii pair<int,int>
#define fi first
#define se second
#define rd random
#define ll long long
#define taskname ""
#define pb push_back
#define mp make_pair
#define pb push_back
#define popb pop_back
#define popf pop_front
#define pf push_front
#define res(a,z,n) for(int i = 1 ; i<=n ; i ++) a[i] = z;
/*-------------------necesary---------------------*/
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
/*------------------limit-------------------------*/
const int base  = 1e9+7;
const int oo = 2003;
const int inf  = INT_MAX;
/*-----------------globalvari-----------------------*/
int n,m,k,q;
int maxf,s,t,S;
vector<int> a[oo];
int cap[oo][oo];
int f[oo][oo];
int cost[oo][oo];
int st[oo],en[oo];
int ans[oo];
int costt[oo];
int stt[oo][oo];
int N;
/*-----------------code-----------------------*/

void input()
{
    cin>>n>>m;
    int x;
    for(int i=1;i<=n;i++)
    {
        cin>>st[i]>>x>>costt[i];
        en[i] = st[i] + x;
    }
}

void compress(vector<int> &a)
{
    int n = a.size();
    set<int> s(a.begin(),a.end());
    vector<int> b(s.begin(),s.end());
    for(int i=0;i<n;i++)
        a[i] = upper_bound(b.begin(),b.end(),a[i]) - b.begin();
}

void khoitao(int x,int y,int c,int z)
{
  //  cerr<<x<<" "<<y<<endl;
    a[x].pb(y);
    a[y].pb(x);
    cost[x][y] = c;
    cost[y][x] = -c;
    cap[x][y] = z;
}

void cre()
{
    vector<int> pos;
    for(int i=1;i<=n;i++)
    {
        pos.pb(st[i]);
        pos.pb(en[i]);
    }
    compress(pos);
    N = pos.size();
    N*=2;
    int cur = 0;
    for(int i=1;i<=n;i++)
    {
        st[i] = pos[cur++]*2 ;
        en[i] = pos[cur++]*2 ;
    }
    for(int i=1;i<=n;i++)
    {
        stt[st[i]][en[i]] = i;
        khoitao(st[i],en[i],-costt[i],1);
    }

    s = 0;
    t = N + 2;

    for(int i = 0 ; i < N+2 ; i ++)
    {
        khoitao(i,i+1,0,m);
    }

}

int inq[oo];
int tr[oo];
int d[oo];

bool fp()
{
    queue<int> q;
    for(int i=1;i<=t;i++)
    {
        inq[i] = 0;
        tr[i] = 0;
        d[i] = inf;
    }

    q.push(s);
    inq[s] = 0;
    d[s] = 0;
    //cerr<<t<<endl;
    while(!q.empty())
    {
        int u = q.front();
        q.pop();
        inq[u] = 0;
        for(int i = 0 ; i < a[u].size() ; i++)
        {
            int v = a[u][i];
            if(cap[u][v] > f[u][v])
            {
                int uv = cost[u][v];
               // if(f[u][v] < 0) uv = -uv;
                if(d[v] > d[u] + uv)
                {
                    tr[v] = u;
                    d[v] = d[u] + uv;
                    if(inq[v] == 0)
                    {
                        inq[v] = 1;
                        q.push(v);
                    }
                }
            }
        }
    }

    return tr[t];
}

int minc ;

void IncFlow()
{
    int D = inf;

    for(int i = t ; i != s ; i = tr[i] )
    {
        int u =tr[i];
      //  cerr<<u<<" "<<i<<endl;
        if(f[u][i] >= 0)
        D = min(D,cap[u][i] - f[u][i]);
        else D = min(D,-f[u][i]);
    }
   // cerr<<endl;
    for(int i = t ; i != s ; i = tr[i] )
    {
        int u = tr[i];
        f[u][i] += D;
        f[i][u] -= D;
    }
   // cerr<<D<<endl;
    minc += D*d[t];
    maxf += D;
}

void solve()
{
    cre();
    while(fp()) IncFlow();

   // cerr<<maxf<<endl;

    for(int i=1;i<=N;i++)
    {
        for(int j=i+1;j<=N;j++)
        {
            if(cap[i][j] = 1 && f[i][j]) ans[stt[i][j]] = 1;
        }
    }

    for(int i=1;i<=n;i++)
        cout<<ans[i]<<" ";

    //if(maxf < S) {cout<<-1;return ;}
    //cout<<"0 0 0";
    //main code here :))
}

void ouput()
{
    //int ns = n + 1 ;

    //a[ns].pb(s);

    //write
}

int32_t main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //#ifndef ONLINE_JUDGES
    if (ifstream("test.txt"))
    {
        freopen("test.txt", "r", stdin);
        #ifdef CHECKING
            freopen(taskname".out", "w", stdout);
        #else
            //\freopen("test.out", "w", stdout);
        #endif //CHECKING
    }
    else if (ifstream(taskname".inp"))
    {
        freopen(taskname".inp", "r", stdin);
        freopen(taskname".out", "w", stdout);
    }
    //#endif // ONLINE_JUDGES
    int t=1;
   // cin>>t;

    while(t--)
    {
    input();
    solve();
    ouput();
    }
}

//ilove??<3


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

struct edge{
    int to,cap,cost,rev;
    edge(){
        to=cap=cost=rev=0;
    }
    edge(int _t,int _c,int _cc,int _r){
        to=_t;
        cap=_c;
        cost=_cc;
        rev=_r;
    }
};

int V;
vector<edge> g[2005];
int h[2005];
int dist[2005];
int prevv[2005],preve[2005];

int addedge(const int &from,const int &to,const int &cap,const int &cost){
    g[from].emplace_back(to,cap,cost,g[to].size());
    g[to].emplace_back(from,0,-cost,g[from].size()-1);
    return g[from].size()-1;
}

int min_cost_flow(const int &src,const int &dst,int flow){
    int res=0;
    memset(h,0,sizeof(h));
    while(flow>0){
        priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
        memset(dist,0x3f,sizeof(dist));
        dist[src]=0;
        pq.emplace(0,src);
        while(!pq.empty()){
            int x=pq.top().second,cd=pq.top().first;
            pq.pop();
            if(cd>dist[x])continue;
            for(int i=0;i<g[x].size();i++){
                edge &e=g[x][i];
                if(e.cap&&dist[e.to]>dist[x]+e.cost+h[x]-h[e.to]){
                    dist[e.to]=dist[x]+e.cost+h[x]-h[e.to];
                    prevv[e.to]=x;
                    preve[e.to]=i;
                    pq.emplace(dist[e.to],e.to);
                }
            }
        }
        if(dist[dst]==0x3f3f3f3f)return -1;
        for(int v=0;v<=V;v++){
            h[v]+=dist[v];
        }
        int cflow=flow;
        for(int v=dst;v!=src;v=prevv[v]){
            cflow=min(cflow,g[prevv[v]][preve[v]].cap);
        }
        flow-=cflow;
        res+=cflow*h[dst];
        for(int v=dst;v!=src;v=prevv[v]){
            g[prevv[v]][preve[v]].cap-=cflow;
            g[v][g[prevv[v]][preve[v]].rev].cap+=cflow;
        }
    }
    return res;
}

int n,k,src,dst;
int s[1005],t[1005],c[1005];
vector<int> dsc;
vector<pair<int,int>> ansv;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for(int i=1;i<=n;i++){
        cin>>s[i]>>t[i]>>c[i];
        t[i]=s[i]+t[i];
        dsc.emplace_back(s[i]);
        dsc.emplace_back(t[i]);
    }
    sort(dsc.begin(),dsc.end());
    dsc.erase(unique(dsc.begin(),dsc.end()),dsc.end());
    src=1;
    dst=dsc.size();
    for(int i=src;i<dst;i++){
        addedge(i,i+1,k,0);
    }
    for(int i=1;i<=n;i++){
        s[i]=lower_bound(dsc.begin(),dsc.end(),s[i])-dsc.begin()+1;
        t[i]=lower_bound(dsc.begin(),dsc.end(),t[i])-dsc.begin()+1;
        ansv.emplace_back(s[i],addedge(s[i],t[i],1,-c[i]));
    }
    cerr<<-min_cost_flow(src,dst,k)<<endl;
    for(pair<int,int> &p:ansv){
        cout<<(g[p.first][p.second].cap==0)<<' ';
    }

    return 0;
}


#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define dd(x) cout<<#x<<"="<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define db double
#define all(a) a.begin(),a.end()
const int mod = 1e9+7;
const int maxn = 2e6+6;
const double eps = 1e-6;
using namespace std;
bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n,m,tot,s=0,t;
bool in[maxn];
int dis[maxn];
int ans[maxn]={0};
int path[maxn],q[maxn];
int pre[maxn];
map<int,int> tim_id;
vector<int> tim;
struct edge{
	int u,v,w,c,nt,id;
}e[maxn];
struct Task{
	int st,ed,c,id;
}task[maxn];
void add(int u,int v,int w,int c,int id=0){
	e[tot].u=u;e[tot].v=v;e[tot].w=w;e[tot].c=c;e[tot].id=id;e[tot].nt=pre[u];
	pre[u]=tot++;
	e[tot].u=v;e[tot].v=u;e[tot].w=0;e[tot].c=-c;e[tot].id=id;e[tot].nt=pre[v];
	pre[v]=tot++;
}
void init(){
	tot=0;
	mt(pre,-1);
}
bool spfa(){
	mt(path,-1);mt(dis,inf);mt(in,false);
	dis[s] = 0;
	int l=0,r=0;
	q[r++]=s;in[s]=true;
	while(l<r){
		int u=q[l++];in[u]=false;
		for(int i=pre[u];~i;i=e[i].nt){
			int v=e[i].v,w=e[i].w,c=e[i].c;
			if(w>0&&dis[v]>dis[u]+c){
				dis[v]=dis[u]+c;
				if(!in[v]) q[r++]=v,in[v]=true;
				path[v]=i;
			}
		}
	}
//	de(dis[t])
	return dis[t]!=inf;
}
int mincost(){
	int ret = 0;
	while(spfa()){
//		de(ret)
		int mnflow = inf;
		for(int i=path[t];~i;i=path[e[i].u]) mnflow=min(mnflow,e[i].w);
		for(int i=path[t];~i;i=path[e[i].u]) e[i].w-=mnflow,e[i^1].w+=mnflow;
		ret += dis[t];
	}
	return ret;
}
void get_ans(){
	rep(u,1,sz(tim)+1){
		for(int i=pre[u];~i;i=e[i].nt){
			int w=e[i].w;
			if(!w&&e[i].u<e[i].v) ans[e[i].id]=1;
		}
	}
}
int main(){
	init();
	scanf("%d%d",&n,&m);
	rep(i,1,n+1) {
		scanf("%d%d%d",&task[i].st,&task[i].ed,&task[i].c);
		task[i].id = i;task[i].ed+=task[i].st-1;
		tim.pb(task[i].st),tim.pb(task[i].ed);
	}
	sort(all(tim));
	tim.erase(unique(all(tim)),tim.end());t=sz(tim)+2;
	rep(i,0,sz(tim)) tim_id[tim[i]]=i+1;
	rep(i,1,sz(tim)+1) add(i-1,i,m,0);
	add(sz(tim),sz(tim)+1,m,0);
	add(sz(tim)+1,sz(tim)+2,m,0);
	rep(i,1,n+1) add(tim_id[task[i].st],tim_id[task[i].ed]+1,1,-task[i].c,i);
	mincost();get_ans();
	rep(i,1,n+1) printf("%d%c",ans[i]," \n"[i==n]);
	return 0;
}


#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define dd(x) cout<<#x<<"="<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define db double
#define all(a) a.begin(),a.end()
const int mod = 1e9+7;
const int maxn = 2e5+6;
const double eps = 1e-6;
using namespace std;
bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n,m,tot,s=0,t;
bool in[maxn];
int dis[maxn];
int ans[maxn];
int path[maxn],q[maxn];
int tim_id[maxn];
int pre[maxn];
vector<int> tim;
struct edge{
	int u,v,w,c,nt,id;
}e[maxn];
struct Task{
	int st,ed,c,id;
}task[maxn];
void add(int u,int v,int w,int c,int id=0){
	e[tot].u=u;e[tot].v=v;e[tot].w=w;e[tot].c=c;e[tot].id=id;e[tot].nt=pre[u];
	pre[u]=tot++;
	e[tot].u=v;e[tot].v=u;e[tot].w=0;e[tot].c=-c;e[tot].id=id;e[tot].nt=pre[v];
	pre[v]=tot++;
}
void init(){
	tot=0;
	mt(pre,-1);
}
bool spfa(){
	mt(path,-1);mt(dis,inf);mt(in,false);
	dis[s] = 0;
	int l=0,r=0;
	q[r++]=s;in[s]=true;
	while(l<r){
		int u=q[l++];in[u]=false;
		for(int i=pre[u];~i;i=e[i].nt){
			int v=e[i].v,w=e[i].w,c=e[i].c;
			if(w>0&&dis[v]>dis[u]+c){
				dis[v]=dis[u]+c;
				if(!in[v]) q[r++]=v,in[v]=true;
				path[v]=i;
			}
		}
	}
//	de(dis[t])
	return dis[t]!=inf;
}
int mincost(){
	int ret = 0;
	while(spfa()){
//		de(ret)
		int mnflow = inf;
		for(int i=path[t];~i;i=path[e[i].u]) mnflow=min(mnflow,e[i].w);
		for(int i=path[t];~i;i=path[e[i].u]) e[i].w-=mnflow,e[i^1].w+=mnflow;
		ret += dis[t];
	}
	return ret;
}
void get_ans(){
	rep(u,1,sz(tim)+1){
		for(int i=pre[u];~i;i=e[i].nt){
			int w=e[i].w;
			if(!w&&e[i].u<e[i].v) ans[e[i].id]=1;
		}
	}
}
int main(){
	init();
	scanf("%d%d",&n,&m);
	rep(i,1,n+1) {
		scanf("%d%d%d",&task[i].st,&task[i].ed,&task[i].c);
		task[i].id = i;task[i].ed+=task[i].st-1;
		tim.pb(task[i].st),tim.pb(task[i].ed);
	}
	sort(all(tim));
	tim.erase(unique(all(tim)),tim.end());t=sz(tim)+2;
	rep(i,0,sz(tim)) tim_id[tim[i]]=i+1;
	rep(i,1,sz(tim)+1) add(i-1,i,m,0);
	add(sz(tim),sz(tim)+1,m,0);
	add(sz(tim)+1,sz(tim)+2,m,0);
	rep(i,1,n+1) add(tim_id[task[i].st],tim_id[task[i].ed]+1,1,-task[i].c,i);
	mincost();get_ans();
	rep(i,1,n+1) printf("%d%c",ans[i]," \n"[i==n]);
	return 0;
}


#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl;
#define dd(x) cout<<#x<<"="<<x<<" ";
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define ll long long
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define pii pair<int,int>
#define pdd pair<double,double>
#define pdi pair<double,int>
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define ull unsigned long long
#define ll long long
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define db double
#define all(a) a.begin(),a.end()
const int mod = 1e9+7;
const int maxn = 2e6+6;
const double eps = 1e-6;
using namespace std;
bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n,m,tot,s=0,t;
bool in[maxn];
int dis[maxn];
int ans[maxn];
int path[maxn],q[maxn];
int tim_id[maxn];
int pre[maxn];
vector<int> tim;
struct edge{
	int u,v,w,c,nt,id;
}e[maxn];
struct Task{
	int st,ed,c,id;
}task[maxn];
void add(int u,int v,int w,int c,int id=0){
	e[tot].u=u;e[tot].v=v;e[tot].w=w;e[tot].c=c;e[tot].id=id;e[tot].nt=pre[u];
	pre[u]=tot++;
	e[tot].u=v;e[tot].v=u;e[tot].w=0;e[tot].c=-c;e[tot].id=id;e[tot].nt=pre[v];
	pre[v]=tot++;
}
void init(){
	tot=0;
	mt(pre,-1);
}
bool spfa(){
	mt(path,-1);mt(dis,inf);mt(in,false);
	dis[s] = 0;
	int l=0,r=0;
	q[r++]=s;in[s]=true;
	while(l<r){
		int u=q[l++];in[u]=false;
		for(int i=pre[u];~i;i=e[i].nt){
			int v=e[i].v,w=e[i].w,c=e[i].c;
			if(w>0&&dis[v]>dis[u]+c){
				dis[v]=dis[u]+c;
				if(!in[v]) q[r++]=v,in[v]=true;
				path[v]=i;
			}
		}
	}
//	de(dis[t])
	return dis[t]!=inf;
}
int mincost(){
	int ret = 0;
	while(spfa()){
//		de(ret)
		int mnflow = inf;
		for(int i=path[t];~i;i=path[e[i].u]) mnflow=min(mnflow,e[i].w);
		for(int i=path[t];~i;i=path[e[i].u]) e[i].w-=mnflow,e[i^1].w+=mnflow;
		ret += dis[t];
	}
	return ret;
}
void get_ans(){
	rep(u,1,sz(tim)+1){
		for(int i=pre[u];~i;i=e[i].nt){
			int w=e[i].w;
			if(!w&&e[i].u<e[i].v) ans[e[i].id]=1;
		}
	}
}
int main(){
	init();
	scanf("%d%d",&n,&m);
	rep(i,1,n+1) {
		scanf("%d%d%d",&task[i].st,&task[i].ed,&task[i].c);
		task[i].id = i;task[i].ed+=task[i].st-1;
		tim.pb(task[i].st),tim.pb(task[i].ed);
	}
	sort(all(tim));
	tim.erase(unique(all(tim)),tim.end());t=sz(tim)+2;
	rep(i,0,sz(tim)) tim_id[tim[i]]=i+1;
	rep(i,1,sz(tim)+1) add(i-1,i,m,0);
	add(sz(tim),sz(tim)+1,m,0);
	add(sz(tim)+1,sz(tim)+2,m,0);
	rep(i,1,n+1) add(tim_id[task[i].st],tim_id[task[i].ed]+1,1,-task[i].c,i);
	mincost();get_ans();
	rep(i,1,n+1) printf("%d%c",ans[i]," \n"[i==n]);
	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(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});
  }
  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);
    fore(j, 0, n) if(i != j) {
      if(ts[i].s + ts[i].t <= ts[j].s) mcf.add_edge(i + n, j, 1, 0);
    }
  }
  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[i] = 1;
  }
  fore(i, 0, n) cout << res[i] << " "; cout << endl;
  return 0;
}