#include <bits/stdc++.h>
int T;
int n, k;
int ans[2010];
struct arc_t {
  int v, c, cap;
  int pair;
  int to_ans;
  arc_t(int _v, int _c, int _cc, int _p, int _t)
      : v(_v), c(_c), cap(_cc), pair(_p), to_ans(_t) {}
};
int S, E;
std::vector<int> dez;
std::vector<arc_t> ee[2010];
void make_edge(int u, int v, int c, int cap, int ans = -1) {
  int us = ee[u].size(), vs = ee[v].size();
  ee[u].push_back(arc_t(v, c, cap, vs, ans));
  ee[v].push_back(arc_t(u, -c, 0, us, -1));
}
int que[2010], qf, qr;
int dst[2010], fa[2010];
unsigned fai[2010];
bool inq[2010];
inline int next(int qq) { return (qq == 2010 - 1) ? 0 : qq + 1; }
int make_flow() {
  int ret = 0;
  while (true) {
    qf = 0;
    qr = 1;
    que[0] = S;
    memset(fa, -1, sizeof(fa));
    memset(inq, 0, sizeof(inq));
    memset(dst, -1, sizeof(dst));
    inq[S] = true;
    dst[S] = 0;
    while (qf != qr) {
      int now = que[qf];
      qf = next(qf);
      for (unsigned i = 0; i < ee[now].size(); i++) {
        arc_t *arc = &ee[now][i];
        int nxt = arc->v;
        if (arc->cap > 0 && dst[nxt] < dst[now] + arc->c) {
          dst[nxt] = dst[now] + ee[now][i].c;
          fa[nxt] = now;
          fai[nxt] = i;
          if (!inq[nxt]) {
            inq[nxt] = true;
            que[qr] = nxt;
            qr = next(qr);
          }
        }
      }
      inq[now] = false;
    }
    if (fa[E] == -1) break;
    int nflow = k + 1;
    for (int i = E; fa[i] != S; i = fa[i]) {
      if (nflow > ee[fa[i]][fai[i]].cap) {
        nflow = ee[fa[i]][fai[i]].cap;
      }
    }
    for (int i = E; fa[i] != S; i = fa[i]) {
      arc_t *arc = &ee[fa[i]][fai[i]];
      arc->cap -= nflow;
      ee[i][arc->pair].cap += nflow;
      ret += nflow * arc->c;
    }
  }
  return ret;
}
int inu[2010], inv[2010], inc[2010];
int main() {
  T = 1;
  for (int tc = 1; tc <= T; tc++) {
    for (int i = 0; i < 2010; i++) ee[i] = std::vector<arc_t>();
    memset(ans, 0, sizeof(ans));
    dez = std::vector<int>();
    dez.push_back(0);
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) {
      scanf("%d%d%d", inu + i, inv + i, inc + i);
      inv[i] += inu[i];
      dez.push_back(inu[i]);
      dez.push_back(inv[i]);
    }
    std::sort(dez.begin(), dez.end());
    dez.resize(std::distance(dez.begin(), std::unique(dez.begin(), dez.end())));
    S = 0;
    E = dez.size();
    for (int i = 0; i < E; i++) {
      make_edge(i, i + 1, 0, k);
    }
    for (int i = 0; i < n; i++) {
      int u, v;
      u = std::distance(dez.begin(),
                        std::lower_bound(dez.begin(), dez.end(), inu[i]));
      v = std::distance(dez.begin(),
                        std::lower_bound(dez.begin(), dez.end(), inv[i]));
      make_edge(u, v, inc[i], 1, i);
    }
    make_flow();
    for (int now = S; now <= E; now++) {
      for (unsigned i = 0; i < ee[now].size(); i++) {
        if (ee[now][i].to_ans != -1) {
          ans[ee[now][i].to_ans] = (ee[now][i].cap == 0);
        }
      }
    }
    for (int i = 0; i < n; i++) {
      printf("%d ", ans[i]);
    }
    puts("");
  }
  return 0;
}
