#include <bits/stdc++.h>
using namespace std;
const int limite = 3010;
const long long int infinito = 10000000000000LL;
int mida;
int final;
vector<int> g[limite];
int capacidad[limite][limite];
long long int coste[limite][limite];
long long int potencial[limite];
int flujo[limite][limite];
long long int dist[limite];
int anterior[limite];
int idsol[limite][limite];
int sol[limite];
void maxflowmincost() {
  for (;;) {
    for (int i = 0; i < mida; i++) dist[i] = infinito;
    priority_queue<pair<long long int, int>, vector<pair<long long int, int> >,
                   greater<pair<long long int, int> > >
        q;
    q.push(pair<long long int, int>(0, 0));
    dist[0] = 0;
    while (not q.empty()) {
      pair<long long int, int> p = q.top();
      q.pop();
      long long int d = p.first;
      int u = p.second;
      if (dist[u] == d) {
        vector<int> &ar = g[u];
        for (int i = 0; i < int(ar.size()); i++) {
          int v = ar[i];
          if (flujo[u][v] >= 0 and capacidad[u][v] > flujo[u][v] and
              dist[u] + coste[u][v] + potencial[u] - potencial[v] < dist[v]) {
            dist[v] = dist[u] + coste[u][v] + potencial[u] - potencial[v];
            anterior[v] = u;
            q.push(pair<long long int, int>(dist[v], v));
          } else if (flujo[u][v] < 0 and
                     dist[u] - coste[v][u] + potencial[u] - potencial[v] <
                         dist[v]) {
            dist[v] = dist[u] - coste[v][u] + potencial[u] - potencial[v];
            anterior[v] = u;
            q.push(pair<long long int, int>(dist[v], v));
          }
        }
      }
    }
    for (int i = 0; i < mida; i++) potencial[i] += dist[i];
    if (dist[final] == infinito) {
      for (int i = 0; i < mida; i++)
        for (int j = 0; j < mida; j++)
          if (idsol[i][j]) sol[idsol[i][j]] = flujo[i][j] == capacidad[i][j];
      return;
    }
    int bot = 1000000000;
    int u = final;
    while (u != 0) {
      int antu = anterior[u];
      if (flujo[antu][u] >= 0)
        bot = min(bot, capacidad[antu][u] - flujo[antu][u]);
      else
        bot = min(bot, flujo[u][antu]);
      u = antu;
    }
    u = final;
    while (u != 0) {
      int antu = anterior[u];
      flujo[antu][u] += bot;
      flujo[u][antu] -= bot;
      u = antu;
    }
  }
}
int n, k;
int s[limite], t[limite], c[limite];
int main() {
  cin >> n >> k;
  map<int, int> pos;
  pos[0];
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> t[i] >> c[i];
    t[i] += s[i];
    pos[s[i]];
    pos[t[i]];
  }
  pos[1000000010];
  {
    int i = 0;
    for (map<int, int>::iterator it = pos.begin(); it != pos.end(); it++, i++)
      it->second = i;
  }
  for (int i = 0; i < int(pos.size()) - 1; i++) {
    g[i].push_back(i + 1);
    g[i + 1].push_back(i);
    capacidad[i][i + 1] = k;
    coste[i][i + 1] = 1000000;
  }
  mida = int(pos.size()) + n;
  final = int(pos.size()) - 1;
  for (int i = 0; i < n; i++) {
    g[pos[s[i]]].push_back(int(pos.size()) + i);
    g[int(pos.size()) + i].push_back(pos[s[i]]);
    idsol[pos[s[i]]][int(pos.size()) + i] = i + 1;
    capacidad[pos[s[i]]][int(pos.size()) + i] = 1;
    coste[pos[s[i]]][int(pos.size()) + i] = 0;
    g[int(pos.size()) + i].push_back(pos[t[i]]);
    g[pos[t[i]]].push_back(int(pos.size()) + i);
    capacidad[int(pos.size()) + i][pos[t[i]]] = 1;
    coste[int(pos.size()) + i][pos[t[i]]] =
        1000000LL * (pos[t[i]] - pos[s[i]]) - c[i];
  }
  maxflowmincost();
  for (int i = 1; i <= n; i++) {
    if (i > 1) cout << " ";
    cout << sol[i];
  }
  cout << endl;
}
