#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
const long double pi = acos(-1.0);
const int N = 5000;
const int INF = (int)2e9 + 10;
struct edge {
  int tov, c, w, rev, f;
  edge(int tov, int c, int w, int rev) : tov(tov), c(c), w(w), rev(rev), f(0) {}
};
vector<edge> adj[N];
int n, k, s[N], t[N], c[N], d[N], p[N], pe[N], res;
bool inq[N];
pair<int, int> ans[N];
vector<int> all;
pair<int, int> add_edge(int u, int v, int c, int w) {
  int unum = ((int)(adj[u]).size()), vnum = ((int)(adj[v]).size());
  adj[u].push_back(edge(v, c, w, vnum));
  adj[v].push_back(edge(u, 0, -w, unum));
  return make_pair(u, ((int)(adj[u]).size()) - 1);
}
int main() {
  scanf("%d%d", &n, &k);
  all.push_back(0);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d", &s[i], &t[i], &c[i]);
    all.push_back(s[i]), all.push_back(s[i] + t[i]);
  }
  all.push_back(INF);
  sort(all.begin(), all.end());
  all.resize(unique(all.begin(), all.end()) - all.begin());
  for (int i = 0; i < n; ++i)
    ans[i] =
        add_edge(lower_bound(all.begin(), all.end(), s[i]) - all.begin(),
                 lower_bound(all.begin(), all.end(), s[i] + t[i]) - all.begin(),
                 1, -c[i]);
  for (int i = 0; i + 1 < ((int)(all).size()); ++i) add_edge(i, i + 1, k, 0);
  int start = 0, finish = ((int)(all).size()) - 1;
  for (int it = 0; it < k; ++it) {
    for (int j = 0; j < ((int)(all).size()); ++j) {
      d[j] = (j == start) ? 0 : INF;
      inq[j] = (j == start);
      p[j] = -1;
    }
    queue<int> q;
    q.push(start);
    while (!q.empty()) {
      int v = q.front();
      q.pop();
      inq[v] = false;
      for (int i = 0; i < ((int)(adj[v]).size()); ++i) {
        int u = adj[v][i].tov;
        if ((adj[v][i].c - adj[v][i].f > 0) && (d[v] + adj[v][i].w < d[u])) {
          d[u] = d[v] + adj[v][i].w;
          p[u] = v, pe[u] = i;
          if (!inq[u]) {
            q.push(u);
            inq[u] = true;
          }
        }
      }
    }
    if (d[finish] == INF) break;
    res += d[finish];
    int u = finish;
    while (u != start) {
      int v = p[u], i = pe[u];
      adj[v][i].f++, adj[u][adj[v][i].rev].f--;
      u = v;
    }
  }
  for (int i = 0; i < n; ++i)
    printf("%d%c", (adj[ans[i].first][ans[i].second].f > 0) ? 1 : 0,
           " \n"[i == n - 1]);
  return 0;
}
