#include <bits/stdc++.h>
using namespace std;
const int adj[8][2] = {{-1, 0},  {0, -1}, {1, 0}, {0, 1},
                       {-1, -1}, {-1, 1}, {1, 1}, {1, -1}};
const long long int LLINF = 9e18;
const int INF = 2e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-10;
const double PI = acos(-1);
const int SIZE = 3333;
int N, k;
struct edge {
  int v, f, c, u;
  long long int cost;
};
struct task {
  long long int v, u;
  long long int cost;
} tsk[SIZE];
vector<edge> E[SIZE];
int st[SIZE], lvl[SIZE];
long long int cost[SIZE];
map<long long int, int> Mp;
vector<long long int> num;
vector<pair<int, int> > pos;
void init() {
  for (int i = 0; i < SIZE; i++) {
    E[i].clear();
  }
}
void addedge(int a, int b, int ca, int cb, long long int cost) {
  edge A = {a, 0, ca, (int)E[a].size(), -cost};
  edge B = {b, 0, cb, (int)E[b].size(), cost};
  E[a].push_back(B);
  E[b].push_back(A);
}
bool Dijkstra(int S, int T) {
  for (int i = 0; i < SIZE; i++) {
    cost[i] = INF;
    lvl[i] = -1;
  }
  priority_queue<pair<int, int> > pq;
  pq.push(make_pair(0, S));
  lvl[S] = 0;
  cost[S] = 0;
  while (!pq.empty()) {
    int indx = pq.top().second;
    int step = -pq.top().first;
    pq.pop();
    if (step > cost[indx]) continue;
    for (int i = 0; i < (int)E[indx].size(); i++) {
      edge &t = E[indx][i];
      int idx = t.v;
      if (cost[idx] > cost[indx] + t.cost && t.c > t.f) {
        cost[idx] = cost[indx] + t.cost;
        lvl[idx] = lvl[indx] + 1;
        pq.push(make_pair(-cost[idx], idx));
      }
    }
  }
  return cost[T] != INF;
}
pair<long long int, long long int> DFS(int indx, int T, int flow) {
  if (indx == T) return pair<int, int>(0, flow);
  for (int &i = st[indx]; i < (int)E[indx].size(); i++) {
    edge &t = E[indx][i];
    int idx = t.v;
    if (lvl[idx] == lvl[indx] + 1 && cost[idx] == cost[indx] + t.cost &&
        t.c > t.f) {
      int cur = min(flow, t.c - t.f);
      pair<int, int> ret = DFS(idx, T, cur);
      ret.first += t.cost;
      if (ret.second > 0) {
        t.f += ret.second;
        E[t.v][t.u].f -= ret.second;
        return ret;
      }
    }
  }
  return pair<int, int>(0, 0);
}
pair<long long int, long long int> MCMF(int S, int T) {
  pair<long long int, long long int> ret = make_pair(0, 0);
  while (Dijkstra(S, T)) {
    memset(st, 0, sizeof(st));
    while (true) {
      pair<long long int, long long int> cur = DFS(S, T, INF);
      if (cur.second == 0) break;
      ret.first += cur.first;
      ret.second += cur.second;
    }
  }
  return ret;
}
int main() {
  int S = 0, T = SIZE - 1;
  scanf("%d %d", &N, &k);
  for (int i = 1; i <= N; i++) {
    scanf("%lld %lld %lld", &tsk[i].v, &tsk[i].u, &tsk[i].cost);
    tsk[i].u += tsk[i].v;
    Mp[tsk[i].v]++;
    Mp[tsk[i].u]++;
  }
  for (__typeof((Mp).begin()) itm = (Mp).begin(); itm != (Mp).end(); itm++) {
    num.push_back(itm->first);
    itm->second = num.size();
  }
  for (int i = 1; i <= N; i++) {
    addedge(S, Mp[tsk[i].v] + N, 0, 1, 0);
    pos.push_back(make_pair(Mp[tsk[i].v] + N, (int)E[Mp[tsk[i].v] + N].size()));
    addedge(Mp[tsk[i].v] + N, Mp[tsk[i].u] + N, 0, 1, -tsk[i].cost);
  }
  for (int i = 1; i < (int)num.size(); i++) {
    addedge(Mp[num[i - 1]] + N, Mp[num[i]] + N, 0, k, 0);
  }
  addedge((int)num.size() + N, T, 0, k, 0);
  pair<long long int, long long int> ans = MCMF(S, T);
  for (int i = 0; i < (int)pos.size(); i++) {
    int v = pos[i].first;
    int u = pos[i].second;
    printf("%d%c", E[v][u].f, i != (int)pos.size() - 1 ? ' ' : '\n');
  }
  return 0;
}
