#include <bits/stdc++.h>
using namespace std;
struct edge {
  long long to, flow, cap, rev, cost, ocost, idx;
};
long long n, k;
vector<edge> e[5000];
long long source, sink;
long long pot[5000], par[5000], pare[5000];
long long ans[5000] = {};
map<long long, long long> m;
long long idx = 0;
long long cnt = 0;
map<pair<long long, long long>, long long> asd;
vector<pair<int, int> > aasd;
void addedge(long long x, long long y, long long cap, long long cost) {
  long long aa = e[y].size(), bb = e[x].size();
  edge a = {y, 0, cap, aa, cost, cost, cnt++};
  edge b = {x, 0, 0, bb, -cost, -cost, n};
  aasd.push_back(make_pair(x, bb));
  e[x].push_back(a);
  e[y].push_back(b);
}
void bf() {
  for (long long i = 0; i <= idx; i++) pot[i] = 999999999999999;
  pot[source] = 0;
  for (long long i = 0; i < idx; i++) {
    for (long long j = 0; j <= idx; j++) {
      if (pot[j] == 999999999999999) continue;
      for (long long k = 0; k < e[j].size(); k++) {
        edge ee = e[j][k];
        long long u = ee.to, cost = ee.cost;
        if (ee.flow < ee.cap && pot[u] > pot[j] + cost) {
          pot[u] = pot[j] + cost;
        }
      }
    }
  }
}
void reduce() {
  for (long long i = 0; i <= idx; i++) {
    if (pot[i] == 999999999999999) continue;
    for (long long j = 0; j < e[i].size(); j++) {
      if (e[i][j].flow < e[i][j].cap) {
        e[i][j].cost += pot[i] - pot[e[i][j].to];
      } else
        e[i][j].cost = 0;
    }
  }
}
long long dijkstra() {
  long long vis[10000] = {};
  for (long long i = 0; i <= idx; i++) {
    pot[i] = 999999999999999;
    par[i] = -1;
    vis[i] = 0;
  }
  pot[source] = 0;
  priority_queue<pair<long long, long long> > pq;
  pq.push(make_pair(0, source));
  while (!pq.empty()) {
    long long x = pq.top().second;
    pq.pop();
    if (vis[x] == 1) continue;
    vis[x] = 1;
    for (long long i = 0; i < e[x].size(); i++) {
      edge ee = e[x][i];
      if (vis[ee.to] == 0 && ee.cap > ee.flow &&
          pot[ee.to] > pot[x] + ee.cost) {
        pot[ee.to] = pot[x] + ee.cost;
        par[ee.to] = x;
        pare[ee.to] = i;
        pq.push(make_pair(-pot[ee.to], ee.to));
      }
    }
  }
  return vis[sink];
}
pair<long long, long long> mcmf() {
  long long maxflow = 0, totalcost = 0;
  bf();
  reduce();
  while (dijkstra()) {
    reduce();
    long long x = sink, flow = 999999999999999;
    while (x != source) {
      flow = min(flow, e[par[x]][pare[x]].cap - e[par[x]][pare[x]].flow);
      x = par[x];
    }
    x = sink;
    while (x != source) {
      edge ee = e[par[x]][pare[x]];
      e[par[x]][pare[x]].flow += flow;
      e[x][ee.rev].flow -= flow;
      totalcost += flow * ee.ocost;
      if (ee.ocost < 0 && ee.idx < n && ee.idx >= 0) {
        ans[ee.idx] = 1;
      }
      x = par[x];
    }
    maxflow += flow;
  }
  return make_pair(maxflow, totalcost);
}
vector<long long> v;
int main() {
  cin >> n >> k;
  long long s[n], t[n], c[n];
  source = 0;
  for (long long i = 0; i < n; i++) {
    cin >> s[i] >> t[i] >> c[i];
    t[i] += s[i];
    if (m[s[i]] == 0) {
      m[s[i]] = ++idx;
      v.push_back(s[i]);
    }
    if (m[t[i]] == 0) {
      v.push_back(t[i]);
      m[t[i]] = ++idx;
    }
    addedge(m[s[i]], m[t[i]], 1, -c[i]);
  }
  sort(v.begin(), v.end());
  long long before = -1;
  for (long long i = 0; i < v.size(); i++) {
    if (i == 0) {
      addedge(source, m[v[i]], k, 0);
    } else
      addedge(m[before], m[v[i]], 9999999999, 0);
    before = v[i];
    sink = m[before];
  }
  mcmf();
  for (long long i = 0; i < n; i++) {
    cout << e[aasd[i].first][aasd[i].second].flow << " ";
  }
  cout << endl;
}
