#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int inf = 0x3f3f3f3f;
const int N = 2e3 + 10, M = 1e6 + 10;
int n, k, s, ps, t, d[N], st[N], vis[N], res[N], cost;
int head[N], nex[M], to[M], w[M], flow[M], tot = 1;
struct node {
  int bg, ed, c, id;
} q[N];
int cmp(node a, node b) { return a.bg < b.bg; }
inline void ade(int a, int b, int c, int d) {
  to[++tot] = b;
  nex[tot] = head[a];
  w[tot] = d;
  flow[tot] = c;
  head[a] = tot;
}
inline void add(int a, int b, int c, int d) {
  ade(a, b, c, d);
  ade(b, a, 0, -d);
}
inline int spfa() {
  memset(st, 0, sizeof st);
  queue<int> q;
  q.push(s);
  memset(d, -inf, sizeof d);
  d[s] = 0;
  vis[s] = 1;
  while (q.size()) {
    int u = q.front();
    q.pop();
    vis[u] = 0;
    for (int i = head[u]; i; i = nex[i]) {
      if (flow[i] && d[to[i]] < d[u] + w[i]) {
        d[to[i]] = d[u] + w[i];
        if (!vis[to[i]]) vis[to[i]] = 1, q.push(to[i]);
      }
    }
  }
  return d[t] >= 0;
}
int dfs(int x, int f) {
  if (x == t) return cost += d[t] * f, f;
  st[x] = 1;
  int fl = 0;
  for (int i = head[x]; i && f; i = nex[i]) {
    if (flow[i] && !st[to[i]] && d[to[i]] == d[x] + w[i]) {
      int mi = dfs(to[i], min(flow[i], f));
      flow[i] -= mi, flow[i ^ 1] += mi, fl += mi, f -= mi;
    }
  }
  return fl;
}
signed main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n >> k;
  t = n * 2 + 1;
  add(s, 1, k, 0);
  for (int i = 1; i <= n; i++) cin >> q[i].bg >> q[i].ed >> q[i].c, q[i].id = i;
  sort(q + 1, q + 1 + n, cmp);
  for (int i = 1; i <= n; i++) {
    add(i, i + n, 1, q[i].c);
    add(i + n, t, inf, 0);
    if (i != n) add(i, i + 1, inf, 0);
    for (int j = i + 1; j <= n; j++) {
      if (q[j].bg > q[i].bg + q[i].ed - 1) {
        add(i + n, j, inf, 0);
        break;
      }
    }
  }
  while (spfa()) dfs(s, inf);
  for (int i = 1; i <= n; i++) {
    for (int j = head[i]; j; j = nex[j])
      if (to[j] == i + n && flow[j ^ 1] && w[j]) res[q[i].id] = 1;
  }
  for (int i = 1; i <= n; i++) cout << res[i] << ' ';
  puts("");
  return 0;
}
