#include <bits/stdc++.h>
using namespace std;
struct edge {
  int from, to, cap, cost, x;
  edge(int from, int to, int cap, int cost)
      : from(from), to(to), cap(cap), cost(cost), x(0){};
  edge(){};
};
int n, m;
edge ve[2010 * 2 * 2010];
int adj[2010][2 * 2010], nadj[2010];
int dist[2010], used[2010], pai[2010], pot[2010];
int dijkstra(int s, int t) {
  memset(dist, 0x3f3f3f3f, sizeof(dist));
  memset(used, 0, sizeof(used));
  dist[s] = 0;
  pai[s] = -1;
  priority_queue<pair<int, int> > q;
  q.push(pair<int, int>(0, s));
  while (!q.empty()) {
    int v = q.top().second;
    q.pop();
    if (used[v]) continue;
    used[v] = 1;
    for (int i = 0; i < (int)nadj[v]; i++) {
      edge &e = ve[adj[v][i]];
      if (e.from == v && e.x < e.cap) {
        int c = dist[v] + pot[v] - pot[e.to] + e.cost;
        if (c < dist[e.to]) {
          pai[e.to] = adj[v][i];
          dist[e.to] = c;
          q.push(pair<int, int>(-c, e.to));
        }
      } else if (e.to == v && e.x) {
        int c = dist[v] + pot[v] - pot[e.from] - e.cost;
        if (c < dist[e.from]) {
          pai[e.from] = adj[v][i];
          dist[e.from] = c;
          q.push(pair<int, int>(-c, e.from));
        }
      }
    }
  }
  return dist[t];
}
pair<int, int> mfmc(int s, int t) {
  memset(nadj, 0, sizeof(nadj));
  for (int i = 0; i < (int)m; i++) {
    int from = ve[i].from, to = ve[i].to;
    adj[from][nadj[from]++] = i;
    adj[to][nadj[to]++] = i;
  }
  int c = 0, f = 0;
  while (dijkstra(s, t) != 0x3f3f3f3f) {
    int v = t, aug = 0x3f3f3f3f;
    while (pai[v] != -1) {
      edge &e = ve[pai[v]];
      if (v == e.to)
        aug = min(aug, e.cap - e.x), v = e.from;
      else
        aug = min(aug, e.x), v = e.to;
    }
    v = t;
    f += aug;
    while (pai[v] != -1) {
      edge &e = ve[pai[v]];
      if (v == e.to)
        e.x += aug, c += aug * e.cost, v = e.from;
      else
        e.x -= aug, c -= aug * e.cost, v = e.to;
    }
    for (int i = 0; i < (int)n; i++) pot[i] = min(0x3f3f3f3f, pot[i] + dist[i]);
  }
  return pair<int, int>(f, c);
}
int va[2010], vb[2010], vc[2010];
void bf(int s, int n, int m) {
  for (int i = 0; i < (int)n; i++) pot[i] = 0x3f3f3f3f;
  pot[s] = 0;
  for (int i = 0; i < (int)n - 1; i++)
    for (int j = 0; j < (int)m; j++) {
      int u = ve[j].from, v = ve[j].to, w = ve[j].cost;
      if (pot[u] != 0x3f3f3f3f && pot[v] > pot[u] + w) pot[v] = pot[u] + w;
    }
}
int vr[2010];
int main() {
  int xn, k;
  while (scanf("%d%d", &xn, &k) == 2) {
    for (int i = 0; i < (int)xn; i++) {
      scanf("%d%d%d", &va[i], &vb[i], &vc[i]);
      vb[i] += va[i];
    }
    m = 0;
    int sa = 2 * xn, t = 2 * xn + 1, s = 2 * xn + 2;
    ve[m++] = edge(s, sa, k, 0);
    ve[m++] = edge(sa, t, k, 0);
    for (int i = 0; i < (int)xn; i++) {
      ve[m++] = edge(2 * i, 2 * i + 1, 1, -vc[i]);
      ve[m++] = edge(sa, 2 * i, 1, 0);
      ve[m++] = edge(2 * i + 1, t, 1, 0);
      for (int j = 0; j < (int)xn; j++)
        if (i != j && va[j] >= vb[i]) ve[m++] = edge(2 * i + 1, 2 * j, 1, 0);
    }
    n = s + 1;
    bf(s, n, m);
    pair<int, int> res = mfmc(s, t);
    memset(vr, 0, sizeof(vr));
    for (int i = 0; i < (int)m; i++)
      if (ve[i].from < sa && ve[i].from % 2 == 0 && ve[i].x > 0)
        vr[ve[i].from / 2] = 1;
    for (int i = 0; i < (int)xn; i++) printf("%d ", vr[i]);
    printf("\n");
  }
  return 0;
}
