#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, neg = 1;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') neg = -1;
    c = getchar();
  }
  while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
  return x * neg;
}
inline void print(long long x) {
  if (x < 0) {
    putchar('-');
    print(abs(x));
    return;
  }
  if (x <= 9)
    putchar(x + '0');
  else {
    print(x / 10);
    putchar(x % 10 + '0');
  }
}
inline long long qpow(long long x, long long e, long long _MOD) {
  long long ans = 1;
  while (e) {
    if (e & 1) ans = ans * x % _MOD;
    x = x * x % _MOD;
    e >>= 1;
  }
  return ans;
}
long long head[100005], ecnt = 1;
struct edge {
  long long to, nxt, cap, cost;
} e[1000005];
inline void addedge(long long u, long long v, long long f, long long c) {
  e[++ecnt].to = v;
  e[ecnt].cap = f;
  e[ecnt].cost = c;
  e[ecnt].nxt = head[u];
  head[u] = ecnt;
}
bool vis[100005];
long long dist[100005], flow[100005], pre[100005], pos[100005];
inline bool spfa(long long s, long long t) {
  memset(vis, 1, sizeof(vis));
  memset(dist, 63, sizeof(dist));
  queue<long long> q;
  vis[s] = 0;
  dist[s] = 0;
  flow[s] = 0x3f3f3f3f3f3f3f3fll;
  q.push(s);
  while (!q.empty()) {
    long long x = q.front();
    vis[x] = true;
    for (long long i = head[x]; i; i = e[i].nxt) {
      long long y = e[i].to;
      if (e[i].cap > 0 && dist[y] > dist[x] + e[i].cost) {
        dist[y] = dist[x] + e[i].cost;
        pos[y] = x;
        pre[y] = i;
        flow[y] = min(flow[x], e[i].cap);
        if (vis[y]) {
          q.push(y);
          vis[y] = false;
        }
      }
    }
    q.pop();
  }
  return dist[t] < 0x3f3f3f3f3f3f3f3fll;
}
inline long long Dinic(long long s, long long t) {
  long long sum = 0;
  while (spfa(s, t)) {
    sum += flow[t] * dist[t];
    for (long long i = t; i != s; i = pos[i]) {
      e[pre[i]].cap -= flow[t];
      e[pre[i] ^ 1].cap += flow[t];
    }
  }
  return sum;
}
long long n = read(), k = read(), id[1005];
long long key[2005], hs[2005], l[1005], r[1005], c[1005], cnt, cnt2;
signed main() {
  for (long long i = 1; i <= n; i++) {
    l[i] = read(), r[i] = read(), c[i] = read();
    r[i] = l[i] + r[i] - 1;
    key[++cnt] = l[i];
    key[++cnt] = r[i];
  }
  sort(key + 1, key + cnt + 1);
  for (long long i = 1; i <= cnt; i++) {
    if (key[i] != key[i - 1]) {
      hs[++cnt2] = key[i];
    }
  }
  for (long long i = 1; i <= n; i++) {
    l[i] = lower_bound(hs + 1, hs + cnt2 + 1, l[i]) - hs;
    r[i] = lower_bound(hs + 1, hs + cnt2 + 1, r[i]) - hs;
    addedge(l[i], r[i] + 1, 1, -c[i]);
    addedge(r[i] + 1, l[i], 0, c[i]);
    id[i] = ecnt;
  }
  for (long long i = 1; i <= cnt2; i++) {
    addedge(i, i + 1, k, 0);
    addedge(i + 1, i, 0, 0);
  }
  addedge(0, 1, k, 0);
  addedge(1, 0, 0, 0);
  addedge(cnt2 + 1, cnt2 + 2, k, 0);
  addedge(cnt2 + 2, cnt2 + 1, 0, 0);
  Dinic(0, cnt2 + 2);
  for (long long i = 1; i <= n; i++) {
    if (e[id[i]].cap == 1) {
      cout << 1 << ' ';
    } else {
      cout << 0 << ' ';
    }
  }
  return 0;
}
