#include <bits/stdc++.h>
using namespace std;
int n, m, S, T, V, num, x, y, t;
int a[2005], b[2005], c[2005], l[2005], v[2005], u[2005], q[2005], f[2005],
    r[2005], dis[2005];
int qd[10005], qn[10005], qc[10005], ql[10005];
void flow() {
  for (int i = 0; i < V; i++) v[i] = -(1 << 30), u[i] = 0;
  v[S] = 0;
  q[0] = S;
  for (int i = 0, j = 0, s = 1; s; i++) {
    if (i == 2005) i = 0;
    u[q[i]] = 0;
    s--;
    for (int k = l[q[i]]; k; k = qn[k])
      if (qc[k] && v[q[i]] + ql[k] > v[qd[k]]) {
        v[qd[k]] = v[q[i]] + ql[k];
        f[qd[k]] = k;
        if (!u[qd[k]]) {
          if (++j == 2005) j = 0;
          s++;
          u[q[j] = qd[k]] = 1;
        }
      }
  }
  if (v[T] == -(1 << 30)) return;
  for (int i = T; i != S; i = qd[f[i] ^ 1]) qc[f[i]]--, qc[f[i] ^ 1]++;
}
void add(int x, int y, int c, int s) {
  qd[++num] = y;
  qn[num] = l[x];
  qc[num] = c;
  ql[num] = s;
  l[x] = num;
  qd[++num] = x;
  qn[num] = l[y];
  qc[num] = 0;
  ql[num] = -s;
  l[y] = num;
}
int main() {
  scanf("%d%d", &n, &m);
  for (int i = (0); i < (n); i++) {
    scanf("%d%d%d", a + i, b + i, c + i);
    dis[t++] = a[i];
    dis[t++] = a[i] + b[i];
  }
  sort(dis, dis + t);
  V = unique(dis, dis + t) - dis;
  S = 0;
  T = V - 1;
  num = 1;
  for (int i = (0); i < (T); i++) add(i, i + 1, m, 0);
  for (int i = (0); i < (n); i++) {
    x = lower_bound(dis, dis + V, a[i]) - dis;
    y = lower_bound(dis, dis + V, a[i] + b[i]) - dis;
    add(x, y, 1, c[i]);
    r[i] = num - 1;
  }
  for (int i = (0); i < (m); i++) flow();
  for (int i = (0); i < (n); i++) printf("%d ", 1 - qc[r[i]]);
  return 0;
}
