#include <bits/stdc++.h>
using namespace std;
void run();
int main() {
  ios::sync_with_stdio(0);
  run();
}
struct edge_t {
  int s, t;
  long long cap, cost;
  edge_t* rev;
};
long long const inf = 1ll << 55ll;
int n;
vector<edge_t*> edge[8016];
edge_t* from[8016];
long long dist[8016];
long long pot[8016];
namespace graph {
edge_t e[8016];
int n = 0;
void add_edge(int s, int t, long long cap, long long cost) {
  for (int i = 2; i--; swap(s, t), cap = 0, cost *= -1, ++n) {
    edge[s].push_back(&(e[n] = {s, t, cap, cost, &e[n ^ 1]}));
  }
}
void clear() {
  while (n) edge[e[--n].s].clear();
}
}  // namespace graph
long long augment() {
  static int bheap[8016];
  static int where[8016];
  int heaps = 0;
  for (int i = n; i--;) from[i] = nullptr, dist[i] = inf, where[i] = -1;
  auto const push = [&heaps](int id, long long val) {
    int i = (~where[id] ? where[id] : where[id] = heaps++) + 1;
    if (!~i) return;
    val = dist[id] = min(val, dist[id]);
    for (; i > 1 and val < dist[bheap[i / 2 - 1]]; i /= 2) {
      where[bheap[i - 1] = bheap[i / 2 - 1]] = i - 1;
    }
    where[bheap[i - 1] = id] = i - 1;
  };
  auto const pop = [&heaps]() {
    int i, j, k, res = bheap[0];
    where[res] = -2;
    if (not --heaps) return res;
    k = bheap[heaps];
    for (i = 0, j = 1; j < heaps; i = j, j = j * 2 + 1) {
      if (dist[k] < dist[bheap[j += (j + 1 < heaps and
                                     dist[bheap[j + 1]] < dist[bheap[j]])]])
        break;
      where[bheap[i] = bheap[j]] = i;
    }
    where[bheap[i] = k] = i;
    return res;
  };
  for (int x = (push(0, dist[0] = 0), 0); heaps and ~(x = pop());)
    for (auto& y : edge[x])
      if (y->cap)
        for (long long d = dist[x] + y->cost + pot[x] - pot[y->t];
             d < dist[y->t]; ++d)
          push(y->t, d), from[y->t] = y, dist[y->t] = d;
  for (int i = n; i--;) pot[i] = min(inf, pot[i] + dist[i]);
  if (not from[n - 1]) return 0;
  long long flow = inf, cost = 0;
  for (int x = n - 1; x; x = from[x]->s)
    flow = min(flow, from[x]->cap), cost += from[x]->cost;
  for (int x = n - 1; x; x = from[x]->s)
    from[x]->cap -= flow, from[x]->rev->cap += flow;
  return flow * cost;
}
long long mcmf() {
  long long res = 0;
  for (int i = n; i--;) pot[i] = 0;
  do res += augment();
  while (from[n - 1]);
  return res;
}
void run() {
  static map<long long, int> renum;
  static long long muner[8016];
  static int s[8016];
  static int t[8016];
  static long long c[8016];
  renum[-1];
  int m, k;
  cin >> m >> k;
  for (int i = 0; i < m; i++) {
    cin >> s[i] >> t[i] >> c[i];
    renum[s[i]], renum[s[i] + t[i]];
  }
  for (auto& i : renum) muner[n] = i.first, i.second = n++;
  for (int i = 0; i < m; i++)
    graph::add_edge(renum[s[i]], renum[s[i] + t[i]], 1,
                    2000000ll * t[i] - c[i]);
  for (int i = n - 1; i-- > 1;)
    graph::add_edge(i, i + 1, k, 2000000ll * (muner[i + 1] - muner[i]));
  graph::add_edge(0, 1, k, 0);
  long long cost = mcmf();
  for (int i = 0; i < m; i++)
    cout << graph::e[i * 2].rev->cap << (i + 1 == m ? '\n' : ' ');
}
