#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
const int inf = 0x3f3f3f3f;
bool vis[maxn];
int n, m, s, t, x, y, z, f, dis[maxn], pre[maxn], last[maxn], flow[maxn],
    maxflow, mincost;
struct Edge {
  int u, to, next, flow, dis;
} edge[3000005];
int head[maxn], num_edge;
queue<int> q;
struct node {
  int s, t, c, id;
} g[1005];
void add(int from, int to, int flow, int dis) {
  edge[++num_edge].next = head[from];
  edge[num_edge].u = from;
  edge[num_edge].to = to;
  edge[num_edge].flow = flow;
  edge[num_edge].dis = dis;
  head[from] = num_edge;
  flow = 0;
  dis = -dis;
  edge[++num_edge].next = head[to];
  edge[num_edge].u = to;
  edge[num_edge].to = from;
  edge[num_edge].flow = flow;
  edge[num_edge].dis = dis;
  head[to] = num_edge;
}
bool spfa(int s, int t) {
  memset(dis, 0x7f, sizeof(dis));
  memset(flow, 0x7f, sizeof(flow));
  memset(vis, 0, sizeof(vis));
  q.push(s);
  vis[s] = 1;
  dis[s] = 0;
  pre[t] = -1;
  while (!q.empty()) {
    int now = q.front();
    q.pop();
    vis[now] = 0;
    for (int i = head[now]; i != -1; i = edge[i].next) {
      if (edge[i].flow > 0 && dis[edge[i].to] > dis[now] + edge[i].dis) {
        dis[edge[i].to] = dis[now] + edge[i].dis;
        pre[edge[i].to] = now;
        last[edge[i].to] = i;
        flow[edge[i].to] = min(flow[now], edge[i].flow);
        if (!vis[edge[i].to]) {
          vis[edge[i].to] = 1;
          q.push(edge[i].to);
        }
      }
    }
  }
  return pre[t] != -1;
}
void MCMF() {
  while (spfa(s, t)) {
    int now = t;
    maxflow += flow[t];
    mincost += flow[t] * dis[t];
    while (now != s) {
      edge[last[now]].flow -= flow[t];
      edge[last[now] ^ 1].flow += flow[t];
      now = pre[now];
    }
  }
}
bool cmp(node a, node b) { return a.s < b.s; }
bool ans[maxn];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  memset(head, -1, sizeof(head));
  num_edge = -1;
  int k;
  cin >> n >> k;
  s = 0, t = n * 2 + 2;
  int tmp = n * 2 + 1;
  add(tmp, t, k, 0);
  for (int i = 1; i <= n; i++) {
    cin >> g[i].s >> g[i].t >> g[i].c;
    g[i].t = g[i].s + g[i].t - 1;
    g[i].id = i;
    add(0, i, 1, 0);
    add(i, i + n, 1, -g[i].c);
    add(i + n, tmp, inf, 0);
  }
  sort(g + 1, g + 1 + n, cmp);
  for (int i = 1; i <= n - 1; i++) {
    add(g[i].id, g[i + 1].id, inf, 0);
    for (int j = i + 1; j <= n; j++)
      if (g[j].s > g[i].t) {
        add(g[i].id + n, g[j].id, inf, 0);
        break;
      }
  }
  MCMF();
  for (int i = 0; i < num_edge; i += 2) {
    if (!edge[i].flow) {
      if (edge[i].u >= 1 && edge[i].u <= n) ans[edge[i].u] = 1;
    }
  }
  for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
  return 0;
}
