#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 40;
int st[20360], to[20360], nt[20360], id[20360], E;
long long w[20360], cap[20360];
long long d[20360], pd[20360], Q[500000];
bool vis[20360];
int src, snk, N;
int S, T;
long long mcmf() {
  long long ans = 0;
  while (true) {
    for (int i = (0); i < (int)(N); i++) d[i] = INF, vis[i] = false, pd[i] = -1;
    int qt = 0, ss = 1;
    Q[qt++] = src;
    d[src] = 0;
    vis[src] = true;
    for (int qh = 0; ss;) {
      int first = Q[qh++];
      if (qh >= 500000) qh -= 500000;
      vis[first] = false;
      ss--;
      for (int i = st[first]; i != -1; i = nt[i]) {
        if (cap[i] == 0) continue;
        if (d[to[i]] > d[first] + w[i]) {
          d[to[i]] = d[first] + w[i];
          pd[to[i]] = i;
          if (!vis[to[i]]) {
            Q[qt++] = to[i];
            if (qt >= 500000) qt -= 500000;
            ss++;
            vis[to[i]] = true;
          }
        }
      }
    }
    if (d[snk] == INF) break;
    long long mn = INF;
    for (int i = snk; i != src; i = to[pd[i] ^ 1]) {
      mn = min(mn, cap[pd[i]]);
    }
    for (int i = snk; i != src; i = to[pd[i] ^ 1]) {
      cap[pd[i]] -= mn;
      cap[pd[i] ^ 1] += mn;
    }
    ans += d[snk] * mn;
  }
  return ans;
}
void add(int first, int second, long long f, long long ww, int id2) {
  nt[E] = st[first];
  to[E] = second;
  cap[E] = f;
  w[E] = ww;
  id[E] = id2;
  st[first] = E++;
  nt[E] = st[second];
  to[E] = first;
  cap[E] = 0;
  w[E] = -ww;
  id[E] = id2;
  st[second] = E++;
}
bool ans[20360];
int main() {
  int n, k;
  while (scanf("%d%d", &n, &k) != EOF) {
    int a[n], b[n], w[n], c[n * 2], nn = 0;
    map<int, int> M;
    for (int i = 0; i < n; i++) {
      scanf("%d%d%d", a + i, b + i, w + i);
      b[i] += a[i];
      c[nn++] = a[i];
      c[nn++] = b[i];
    }
    sort(c, c + nn);
    nn = unique(c, c + nn) - c;
    for (int i = 0; i < nn; i++) M[c[i]] = i;
    E = 0;
    memset(st, -1, sizeof(st));
    for (int i = 0; i < nn - 1; i++) add(i, i + 1, INF, 0, -1);
    for (int i = 0; i < n; i++) {
      add(M[a[i]], M[b[i]], 1, -w[i], i);
    }
    S = nn, T = nn + 1;
    N = T + 1;
    src = S;
    snk = T;
    add(S, 0, k, 0, -1);
    add(nn - 1, T, k, 0, -1);
    mcmf();
    memset(ans, 0, sizeof(ans));
    for (int i = 0; i < N; i++) {
      for (int j = st[i]; j != -1; j = nt[j]) {
        if (cap[j] == 0 && ::w[j] < 0 && id[j] != -1) {
          ans[id[j]] = 1;
        }
      }
    }
    for (int i = 0; i < n; i++) {
      printf("%d%c", ans[i], i == n - 1 ? '\n' : ' ');
    }
  }
  return 0;
}
