#include <bits/stdc++.h>
using namespace std;
int k;
int ans[1005];
struct Cost_flow {
  struct Edge {
    int to, rem, rid, cost;
    Edge() {}
    Edge(int _t, int _r, int _i, int _c) : to(_t), rem(_r), rid(_i), cost(_c) {}
  };
  vector<Edge> G[2005];
  int n, S, T;
  void add_edge(int f, int t, int rem, int cost) {
    G[f].push_back(Edge(t, rem, G[t].size(), cost));
    G[t].push_back(Edge(f, 0, G[f].size() - 1, -cost));
  }
  void init(int _n, int _s, int _t) {
    n = _n, S = _s, T = _t;
    for (int i = 0; i < n; i++) G[i].clear();
  }
  int p[2005], pid[2005], dis[2005], u[2005];
  deque<int> w;
  pair<int, int> flow() {
    int flow = 0, cost = 0;
    while (1) {
      memset(dis, -1, sizeof(dis));
      memset(u, 0, sizeof(u));
      w.clear();
      w.push_back(S), dis[S] = 0, u[S] = 1;
      while (w.size()) {
        int f = w.front();
        w.pop_front();
        u[f] = 0;
        for (int i = 0; i < G[f].size(); i++) {
          Edge e = G[f][i];
          if (e.rem && dis[f] + e.cost > dis[e.to]) {
            dis[e.to] = dis[f] + e.cost;
            p[e.to] = f;
            pid[e.to] = i;
            if (!u[e.to]) u[e.to] = 1, w.push_back(e.to);
          }
        }
      }
      if (dis[T] == -1 || dis[T] == 0) break;
      flow += 1, cost += dis[T];
      int a = T;
      while (a != S) {
        if (G[p[a]][pid[a]].cost > 0) {
          if (0 && ans[a] == 1) printf("a\n");
          ans[p[a]] = 1;
        }
        if (G[p[a]][pid[a]].cost < 0) {
          if (0 && ans[p[a]] == 0) printf("b\n");
          ans[a] = 0;
        }
        G[p[a]][pid[a]].rem -= 1;
        G[a][G[p[a]][pid[a]].rid].rem += 1;
        a = p[a];
      }
    }
    return make_pair(flow, cost);
  }
};
struct Node {
  int type;
  int val;
  int ind;
  Node() {}
  Node(int _t, int _v, int _i) : type(_t), val(_v), ind(_i) {}
};
bool cmp(Node a, Node b) {
  if (a.val == b.val) return a.type < b.type;
  return a.val < b.val;
}
vector<Node> nd;
signed main() {
  Cost_flow s;
  int n;
  scanf("%d %d", &n, &k);
  s.init(2 * n + 2, 0, 2 * n + 1);
  int S, T, C;
  nd.push_back(Node(1, 2000000005, 2 * n + 1));
  int ps = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%d %d %d", &S, &T, &C);
    nd.push_back(Node(1, S, i));
    nd.push_back(Node(0, S + T, n + i));
    s.add_edge(i, n + i, 1, C);
  }
  sort(nd.begin(), nd.end(), cmp);
  if (0)
    for (int i = 0; i < nd.size(); i++)
      printf("  %d %d %d\n", nd[i].type, nd[i].val, nd[i].ind);
  vector<int> w;
  w.clear();
  for (int i = 0; i < nd.size(); i++) {
    if (nd[i].type) {
      for (int j = 0; j < w.size(); j++) {
        s.add_edge(w[j], nd[i].ind, k, 0);
        if (0) printf(" %d %d %d %d\n", w[j], nd[i].ind, k, 0);
      }
      w.clear();
      s.add_edge(ps, nd[i].ind, k, 0);
      ps = nd[i].ind;
    } else
      w.push_back(nd[i].ind);
  }
  memset(ans, 0, sizeof(ans));
  pair<int, int> b = s.flow();
  if (0) printf("flow=%d,cost=%d\n", b.first, b.second);
  for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
  printf("\n");
  return 0;
}
