#include <bits/stdc++.h>
using namespace std;
#pragma warning(disable : 4996)
const long double PI = 3.14159265358979323846;
const long long MOD = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long INF = INT32_MAX;
struct Edge {
  int u, v, cap, flow, cost;
};
vector<vector<int>> g;
vector<Edge> ed;
vector<int> d, pot, par;
int n, start, endd;
void init(int s, int st, int en) {
  n = s;
  start = st;
  endd = en;
  g.resize(n);
  d.resize(n);
  pot.resize(n);
  par.resize(n);
}
void add_edge(int u, int v, int cap, int cost) {
  int p = (int)ed.size();
  ed.push_back({u, v, cap, 0, cost});
  ed.push_back({v, u, 0, 0, -cost});
  g[u].push_back(p);
  g[v].push_back(p + 1);
}
priority_queue<pair<int, int>> qu;
bool dijkstra() {
  fill(d.begin(), d.end(), INF);
  fill(par.begin(), par.end(), -1);
  d[start] = 0;
  qu.push(make_pair(-d[start], start));
  while (!qu.empty()) {
    int v = qu.top().second;
    int cd = -qu.top().first;
    qu.pop();
    if (d[v] != cd) continue;
    for (auto i : g[v]) {
      if (ed[i].flow == ed[i].cap) continue;
      int nv = ed[i].v;
      int nd = cd + ed[i].cost - pot[nv] + pot[v];
      if (nd < d[nv]) {
        d[nv] = nd;
        par[nv] = i;
        qu.push(make_pair(-d[nv], nv));
      }
    }
  }
  return d[endd] < INF;
}
vector<int> restore_path() {
  vector<int> path;
  for (int i = endd; par[i] != -1; i = ed[par[i]].u) {
    path.push_back(par[i]);
  }
  return path;
}
void ford() {
  fill(pot.begin(), pot.end(), INF);
  pot[start] = 0;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < ed.size(); j++) {
      if (pot[ed[j].u] < INF) {
        pot[ed[j].v] = min(pot[ed[j].v], pot[ed[j].u] + ed[j].cost);
      }
    }
  }
}
int solve() {
  ford();
  int ans = 0;
  while (dijkstra()) {
    vector<int> path = restore_path();
    int add = INF;
    for (auto i : path) add = min(add, ed[i].cap - ed[i].flow);
    for (auto i : path) {
      ans += add * ed[i].cost;
      ed[i].flow += add;
      ed[i ^ 1].flow -= add;
    }
    for (int i = 0; i < n; i++) pot[i] += d[i];
  }
  return ans;
}
int main() {
  srand(time(0));
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int k, m;
  cin >> k >> m;
  vector<int> all, s(k), t(k), c(k);
  for (int i = 0; i < k; i++) {
    cin >> s[i] >> t[i] >> c[i];
    all.push_back(s[i]);
    all.push_back(s[i] + t[i]);
  }
  sort(all.begin(), all.end());
  all.resize(unique(all.begin(), all.end()) - all.begin());
  init(all.size() + 2, all.size(), all.size() + 1);
  add_edge(start, 0, m, 0);
  add_edge(all.size() - 1, endd, m, 0);
  for (int i = 0; i < (int)all.size() - 1; i++) {
    add_edge(i, i + 1, m, 0);
  }
  vector<int> eid(k);
  for (int i = 0; i < k; i++) {
    int a = lower_bound(all.begin(), all.end(), s[i]) - all.begin();
    int b = lower_bound(all.begin(), all.end(), s[i] + t[i]) - all.begin();
    eid[i] = g[a].size();
    add_edge(a, b, 1, -c[i]);
  }
  int res = solve();
  for (int i = 0; i < k; i++) {
    int a = lower_bound(all.begin(), all.end(), s[i]) - all.begin();
    cout << ed[g[a][eid[i]]].flow << " ";
  }
}
