#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
const double pi = acos(-1.0);
int dblcmp(double d) {
  if (fabs(d) < eps) return 0;
  return d > eps ? 1 : -1;
}
const int inf = 2139062143;
const int maxn = 3400;
const int maxe = 15010;
vector<int> as;
struct graph {
  struct edge {
    int u, v, c, flow, cost, next, id;
  } a[maxe];
  int start[maxn], tot, n, m;
  int s, t, pre[maxe];
  void init() {
    memset(start, -1, sizeof(start));
    tot = 0;
  }
  void _addedge(int u, int v, int flow, int cost, int z) {
    a[tot].u = u;
    a[tot].v = v;
    a[tot].c = a[tot].flow = flow;
    a[tot].cost = cost;
    a[tot].next = start[u];
    a[tot].id = z;
    start[u] = tot++;
  }
  void addedge(int u, int v, int flow, int cost, int z) {
    _addedge(u, v, flow, cost, z);
    _addedge(v, u, 0, -cost, z);
  }
  int d[maxn];
  bool qu[maxn];
  int spfa() {
    int i, j, k, tmp;
    memset(d, 0x7f, sizeof(d));
    d[s] = 0;
    queue<int> q;
    q.push(s);
    pre[s] = -1;
    qu[s] = 1;
    while (!q.empty()) {
      tmp = q.front();
      q.pop();
      qu[tmp] = 0;
      for (i = start[tmp]; i != -1; i = a[i].next) {
        k = a[i].cost;
        j = a[i].v;
        if (a[i].flow && d[j] > d[tmp] + k) {
          d[j] = d[tmp] + k;
          if (!qu[j]) {
            q.push(j);
            qu[j] = 1;
          }
          pre[j] = i;
        }
      }
    }
    return d[t];
  }
  int ek() {
    int mi, i, j, k;
    int ans = 0, ansc = 0;
    while (1) {
      k = spfa();
      if (k == inf) break;
      mi = inf;
      for (i = t; i != s; i = a[pre[i] ^ 1].v) {
        mi = min(mi, a[pre[i]].flow);
      }
      ans += mi;
      ansc += mi * k;
      for (i = t; i != s; i = a[pre[i] ^ 1].v) {
        a[pre[i]].flow -= mi;
        a[pre[i] ^ 1].flow += mi;
      }
    }
    return ansc;
  }
  int bfs() {
    int i, j, k;
    queue<int> q;
    q.push(s);
    memset(pre, -1, sizeof(pre));
    pre[s] = -1;
    while (!q.empty()) {
      int tmp = q.front();
      q.pop();
      for (i = start[tmp]; i != -1; i = a[i].next) {
        if (i % 2 == 0 && a[i].flow < a[i].c && pre[a[i].v] == -1 &&
            a[i].v != s) {
          q.push(a[i].v);
          pre[a[i].v] = i;
        }
      }
    }
    return pre[t];
  }
  void gao() {
    int i;
    while (bfs() != -1) {
      for (i = t; i != s; i = a[pre[i] ^ 1].v) {
        as.push_back(a[pre[i]].id);
        a[pre[i]].flow++;
        a[pre[i] ^ 1].flow--;
      }
    }
  }
} g;
long long a[3100], b[3100], c[3100];
int main() {
  int i, j, k, n, cas = 1;
  while (cas--) {
    scanf("%d%d", &n, &k);
    vector<long long> d;
    for (i = 0; i < n; i++) {
      long long x;
      scanf("%I64d%I64d%I64d", a + i, &x, c + i);
      b[i] = a[i] + x - 1;
      a[i] *= 2;
      b[i] *= 2;
      a[i]--;
      b[i]++;
      d.push_back(a[i]);
      d.push_back(b[i]);
    }
    sort(d.begin(), d.end());
    d.erase(unique(d.begin(), d.end()), d.end());
    for (i = 0; i < n; i++) {
      a[i] = lower_bound(d.begin(), d.end(), a[i]) - d.begin() + 1;
      b[i] = lower_bound(d.begin(), d.end(), b[i]) - d.begin() + 1;
    }
    g.init();
    for (i = 0; i <= 2 * n; i++) {
      int x = inf;
      if (i == 0 || i == 2 * n) x = k;
      g.addedge(i, i + 1, x, 0, -1);
    }
    g.s = 0;
    g.t = 2 * n + 1;
    for (i = 0; i < n; i++) {
      g.addedge(a[i], b[i], 1, -c[i], i);
    }
    g.ek();
    g.gao();
    sort(as.begin(), as.end());
    as.erase(unique(as.begin(), as.end()), as.end());
    int ok[1111] = {0};
    for (i = 0; i < (int)((as).size()); i++)
      if (as[i] >= 0) ok[as[i]] = 1;
    for (i = 0; i < n; i++) printf("%d\n", ok[i]);
  }
  return 0;
}
