#include <bits/stdc++.h>
using namespace std;
struct edge {
  int v;
  int u;
  int64_t cost;
  int64_t cap;
  int64_t flow;
};
int n, s, t, min_cost;
vector<vector<int>> g;
vector<edge> edges;
vector<int64_t> d, p;
vector<int> par;
vector<bool> used;
void add_edge(int v, int u, int64_t cost, int64_t cap) {
  g[v].push_back(edges.size());
  edges.push_back({v, u, cost, cap, 0});
  g[u].push_back(edges.size());
  edges.push_back({u, v, -cost, 0, 0});
}
int64_t pcost(int ed) {
  edge& e = edges[ed];
  if (p[e.v] == INT64_MAX) return INT64_MAX;
  return e.cost + p[e.v] - p[e.u];
}
bool bellman_ford() {
  p.assign(n, INT64_MAX);
  par.assign(n, -1);
  p[s] = 0;
  for (int i = 0; i < n - 1; ++i) {
    for (int j = 0; j < (int)edges.size(); ++j) {
      edge& e = edges[j];
      if (e.flow == e.cap || p[e.v] == INT64_MAX) continue;
      if (p[e.u] > p[e.v] + e.cost) {
        p[e.u] = p[e.v] + e.cost;
        par[e.u] = j;
      }
    }
  }
  return p[t] != INT64_MAX;
}
bool potential_dijkstra() {
  d.assign(n, INT64_MAX);
  d[s] = 0;
  set<pair<int64_t, int>> st;
  st.insert({d[s], s});
  while (!st.empty()) {
    int v = st.begin()->second;
    int64_t dv = st.begin()->first;
    st.erase(st.begin());
    if (dv != d[v]) continue;
    if (dv == INT64_MAX) break;
    for (auto ed : g[v]) {
      edge& e = edges[ed];
      if (e.flow == e.cap) continue;
      if (d[e.u] > d[e.v] + pcost(ed)) {
        d[e.u] = d[e.v] + pcost(ed);
        par[e.u] = ed;
        st.insert({d[e.u], e.u});
      }
    }
  }
  return d[t] != INT64_MAX;
}
int64_t mincost_flow(int64_t flow) {
  if (!bellman_ford()) return 0;
  int64_t cflow = 0;
  int64_t cost = 0;
  while (cflow < flow) {
    int cur = t;
    int64_t push = INT64_MAX;
    while (cur != s) {
      edge& e = edges[par[cur]];
      push = min(push, e.cap - e.flow);
      cur = e.v;
    }
    if (!push) break;
    cflow += push;
    cur = t;
    while (cur != s) {
      edge& e = edges[par[cur]];
      e.flow += push;
      edges[par[cur] ^ 1].flow -= push;
      cost += push * e.cost;
      cur = e.v;
    }
    if (!bellman_ford()) break;
  }
  return cost;
}
struct task {
  int s, t, c, id;
  bool work;
};
int main() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int nn, k;
  cin >> nn >> k;
  vector<task> tt(nn);
  n = nn + 2;
  s = nn;
  t = nn + 1;
  g.resize(n);
  for (int i = 0; i < nn; ++i) {
    cin >> tt[i].s >> tt[i].t >> tt[i].c;
    tt[i].id = i;
    tt[i].work = false;
  }
  sort(tt.begin(), tt.end(), [](task const& a, task const& b) {
    return a.s < b.s || (a.s == b.s && a.t < b.t);
  });
  add_edge(s, 0, 0, INT64_MAX);
  for (int i = 0; i < nn; ++i) {
    if (i < nn - 1)
      add_edge(i, i + 1, 0, INT64_MAX);
    else
      add_edge(i, t, 0, INT64_MAX);
    int j = lower_bound(tt.begin(), tt.end(), tt[i].s + tt[i].t,
                        [](task const& t, int tm) { return t.s < tm; }) -
            tt.begin();
    if (j < nn)
      add_edge(i, j, -tt[i].c, 1);
    else
      add_edge(i, t, -tt[i].c, 1);
  }
  mincost_flow(k);
  for (auto const& e : edges)
    if (e.flow > 0 && e.cost != 0) tt[e.v].work = true;
  sort(tt.begin(), tt.end(),
       [](task const& a, task const& b) { return a.id < b.id; });
  for (auto const& ttt : tt) cout << ttt.work << ' ';
  cout << '\n';
  return 0;
}
