#include <bits/stdc++.h>
using namespace std;
namespace Bartek {
const int MAXN = 600;
typedef int T;
const T INF = INT_MAX;
int n, s, t;
int edge[MAXN][MAXN];
T weight[MAXN][MAXN];
T dist[MAXN], old_dist[MAXN];
bool proc[MAXN];
int prev[MAXN], cnt[MAXN];
pair<int, T> compute_flow() {
  fill_n(old_dist, n, 0);
  for (int k = (0); k < (n - 1); ++k)
    for (int i = (0); i < (n); ++i)
      for (int j = (0); j < (n); ++j)
        if (edge[i][j])
          old_dist[j] = min(old_dist[j], old_dist[i] + weight[i][j]);
  pair<int, T> res(0, 0);
  for (;;) {
    fill_n(dist, n, INF);
    fill_n(proc, n, false);
    dist[s] = 0;
    cnt[s] = INT_MAX;
    for (;;) {
      int cur;
      T best = INF;
      for (int i = (0); i < (n); ++i)
        if (!proc[i] && dist[i] != INF && dist[i] - old_dist[i] < best) {
          cur = i;
          best = dist[i] - old_dist[i];
        }
      if (best == INF) break;
      for (int i = (0); i < (n); ++i)
        if (edge[cur][i] && dist[cur] + weight[cur][i] < dist[i]) {
          prev[i] = cur;
          cnt[i] = min(cnt[cur], edge[cur][i]);
          dist[i] = dist[cur] + weight[cur][i];
        }
      old_dist[cur] = dist[cur];
      proc[cur] = true;
    }
    if (dist[t] == INF) return res;
    res.first += cnt[t];
    res.second += cnt[t] * dist[t];
    for (int i = t; i != s; i = prev[i]) {
      edge[prev[i]][i] -= cnt[t];
      edge[i][prev[i]] += cnt[t];
    }
  }
}
}  // namespace Bartek
namespace Adam {
const int N = 10000;
const int INF = 1000 * 1000 * 1000;
struct edge {
  int from, v;
  int cost, cap, dist, flow, id;
  int revIndex;
  bool residual() { return flow < cap; }
  edge(int _f, int _v, int _cap, int _cost, int _id)
      : from(_f),
        v(_v),
        cost(_cost),
        dist(_cost),
        cap(_cap),
        flow(0),
        id(_id) {}
};
int n, s, t, d[N];
vector<edge>::iterator p[N];
vector<edge> g[N];
bool queued[N];
void bellmanFord() {
  for (int i = 0; i < (n); ++i) {
    d[i] = INF;
    queued[i] = 0;
  }
  queue<int> q;
  d[s] = 0;
  q.push(s);
  queued[s] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    queued[u] = 0;
    for (__typeof((g[u]).begin()) i = (g[u]).begin(); i != (g[u]).end(); ++i)
      if (i->residual() && d[i->v] > d[u] + i->dist) {
        d[i->v] = d[u] + i->dist;
        p[i->v] = i;
        if (!queued[i->v]) {
          q.push(i->v);
          queued[i->v] = 1;
        }
      }
  }
}
void dijkstra() {
  for (int i = 0; i < (n); ++i) {
    d[i] = INF;
  }
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      q;
  d[s] = 0;
  q.push(make_pair(0, s));
  while (!q.empty()) {
    int u = q.top().second;
    int dist = q.top().first;
    q.pop();
    if (dist != d[u]) continue;
    for (__typeof((g[u]).begin()) i = (g[u]).begin(); i != (g[u]).end(); ++i)
      if (i->residual() && d[i->v] > d[u] + i->dist) {
        d[i->v] = d[u] + i->dist;
        p[i->v] = i;
        q.push(make_pair(d[i->v], i->v));
      }
  }
}
void usePotentials() {
  for (int u = 0; u < (n); ++u)
    for (__typeof((g[u]).begin()) i = (g[u]).begin(); i != (g[u]).end(); ++i)
      i->dist = i->dist + d[i->from] - d[i->v];
}
int FLOW, COST;
void fordFulkerson() {
  FLOW = COST = 0;
  for (;;) {
    bellmanFord();
    if (d[t] == INF) break;
    int cost = 0;
    for (int u = t; u != s; u = p[u]->from) {
      p[u]->flow++;
      g[p[u]->v][p[u]->revIndex].flow--;
      cost += p[u]->cost;
    }
    FLOW++;
    COST += cost;
  }
}
void fordFulkersonDijkstra() {
  FLOW = COST = 0;
  bellmanFord();
  usePotentials();
  for (;;) {
    dijkstra();
    usePotentials();
    if (d[t] == INF) break;
    int cost = 0;
    for (int u = t; u != s; u = p[u]->from) {
      p[u]->flow++;
      g[p[u]->v][p[u]->revIndex].flow--;
      cost += p[u]->cost;
    }
    FLOW++;
    COST += cost;
  }
}
void addEdge(int a, int b, int f, int c, int id) {
  g[a].push_back(edge(a, b, f, c, id));
  g[b].push_back(edge(b, a, 0, -c, id));
  g[a].back().revIndex = g[b].size() - 1;
  g[b].back().revIndex = g[a].size() - 1;
}
}  // namespace Adam
int N, S, T;
list<pair<pair<int, int>, pair<int, int> > > E;
const int ADAM = 0;
const int DIJKSTRA = 1;
const int BARTEK = 2;
int option = 1;
pair<int, int> minCostMaxFlow() {
  if (option == ADAM) {
    Adam::n = N;
    Adam::s = S;
    Adam::t = T;
    for (int i = 0; i < (N); ++i) Adam::g[i].clear();
    int id = 0;
    for (__typeof((E).begin()) it = (E).begin(); it != (E).end(); ++it)
      Adam::addEdge(it->first.first, it->first.second, it->second.first,
                    it->second.second, id++);
    Adam::fordFulkerson();
    return pair<int, int>(Adam::FLOW, Adam::COST);
  } else if (option == DIJKSTRA) {
    Adam::n = N;
    Adam::s = S;
    Adam::t = T;
    for (int i = 0; i < (N); ++i) Adam::g[i].clear();
    int id = 0;
    for (__typeof((E).begin()) it = (E).begin(); it != (E).end(); ++it)
      Adam::addEdge(it->first.first, it->first.second, it->second.first,
                    it->second.second, id++);
    Adam::fordFulkersonDijkstra();
    return pair<int, int>(Adam::FLOW, Adam::COST);
  } else {
    Bartek::n = N;
    Bartek::s = S;
    Bartek::t = T;
    for (int i = 0; i < (N); ++i)
      for (int j = 0; j < (N); ++j)
        Bartek::edge[i][j] = Bartek::weight[i][j] = 0;
    for (__typeof((E).begin()) it = (E).begin(); it != (E).end(); ++it) {
      Bartek::edge[it->first.first][it->first.second] = it->second.first;
      Bartek::weight[it->first.first][it->first.second] = it->second.second;
      Bartek::weight[it->first.second][it->first.first] = -it->second.second;
    }
    return Bartek::compute_flow();
  }
}
bool result[111111];
int n;
int s[111111], t[111111], c[111111];
void solve() {
  pair<int, int> xxx = minCostMaxFlow();
  if (option == ADAM || option == DIJKSTRA) {
    for (int i = 0; i < (Adam::n); ++i)
      for (__typeof((Adam::g[i]).begin()) it = (Adam::g[i]).begin();
           it != (Adam::g[i]).end(); ++it)
        if (it->cost < 0) {
          result[it->id] = (it->flow > 0);
        }
  } else {
    for (int i = 0; i < (n); ++i) result[i] = Bartek::edge[s[i]][t[i]] == 0;
  }
}
int main() {
  int k;
  scanf("%d%d", &n, &k);
  vector<pair<int, int> > V;
  for (int i = 0; i < (n); ++i) {
    scanf("%d%d%d", &s[i], &t[i], &c[i]);
    t[i] += s[i];
    V.push_back(pair<int, int>(s[i], i + 1));
    V.push_back(pair<int, int>(t[i], -i - 1));
  }
  sort(V.begin(), V.end());
  for (int i = 0; i < (2 * n); ++i) {
    int job = abs(V[i].second) - 1;
    if (V[i].second < 0)
      t[job] = i + 1;
    else
      s[job] = i + 1;
  }
  int K = 2 * n + 1;
  N = K + 1;
  S = 0;
  T = K;
  for (int i = 0; i < (n); ++i)
    E.push_back(make_pair(make_pair(s[i], t[i]), make_pair(1, -c[i])));
  E.push_back(make_pair(make_pair(0, 1), make_pair(k, 0)));
  V.push_back(pair<int, int>(0, 1));
  for (int i = 0; i < (V.size() - 1); ++i) {
    for (int j = (i + 1); j < (V.size()); ++j) {
      if (V[j].second > 0) {
        E.push_back(make_pair(make_pair(i + 1, j + 1), make_pair(k, 0)));
        break;
      }
    }
  }
  solve();
  for (int i = 0; i < (n); ++i) printf("%d ", result[i]);
  printf("\n");
}
