#include <bits/stdc++.h>
using namespace std;
void run();
int main() {
  ios::sync_with_stdio(0);
  run();
}
long long const inf = 1ll << 55ll;
int n;
struct e_t {
  int s, t;
  long long cap, cost;
  e_t* rev;
  static e_t E[];
  static int N;
};
e_t e_t::E[8016];
int e_t::N = 0;
vector<e_t*> edge[8016];
bool done[8016];
e_t* from[8016];
long long dist[8016];
long long pot[8016];
void add_edge(int s, int t, long long cap, long long cost) {
  e_t::E[e_t::N] = {s, t, cap, cost, e_t::E + e_t::N + 1};
  edge[s].push_back(e_t::E + e_t::N++);
  e_t::E[e_t::N] = {t, s, 0, -cost, e_t::E + e_t::N - 1};
  edge[t].push_back(e_t::E + e_t::N++);
}
long long augment() {
  for (int i = n; i--;) done[i] = false, from[i] = nullptr, dist[i] = inf;
  priority_queue<pair<long long, int>> todo;
  for (todo.push(make_pair(dist[0] = 0, 0)); not todo.empty();) {
    int x = todo.top().second;
    todo.pop();
    if (done[x])
      continue;
    else
      done[x] = true;
    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] and not done[y->t]; ++d)
          todo.push(make_pair(-d, y->t)), 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 (done[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++)
    add_edge(renum[s[i]], renum[s[i] + t[i]], 1, 2000000ll * t[i] - c[i]);
  for (int i = n - 1; i-- > 1;)
    add_edge(i, i + 1, k, 2000000ll * (muner[i + 1] - muner[i]));
  add_edge(0, 1, k, 0);
  long long cost = mcmf();
  for (int i = 0; i < m; i++)
    cout << e_t::E[i * 2].rev->cap << (i + 1 == m ? '\n' : ' ');
}
