#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int base = 1e9 + 7;
const int oo = 4003;
const int inf = INT_MAX;
int n, m, k, q;
int maxf, s, t, S;
vector<int> a[oo];
int cap[oo * 4];
int f[oo * 4];
int cost[oo * 4];
int val[oo * 4];
int st[oo], en[oo];
int ans[oo];
int costt[oo];
int N;
vector<int> adj[oo];
void input() {
  cin >> n >> m;
  int x;
  for (int i = 1; i <= n; i++) {
    cin >> st[i] >> x >> costt[i];
    en[i] = st[i] + x;
  }
}
void compress(vector<int> &a) {
  int n = a.size();
  set<int> s(a.begin(), a.end());
  vector<int> b(s.begin(), s.end());
  for (int i = 0; i < n; i++)
    a[i] = upper_bound(b.begin(), b.end(), a[i]) - b.begin();
}
void khoitao(int x, int y, int c, int z, int i) {
  adj[x].push_back(i);
  adj[y].push_back(i ^ 1);
  cost[i] = c;
  val[i] = y;
  cost[i ^ 1] = -c;
  cap[i] = z;
  val[i ^ 1] = x;
}
void cre() {
  vector<int> pos;
  for (int i = 1; i <= n; i++) {
    pos.push_back(st[i]);
    pos.push_back(en[i]);
  }
  compress(pos);
  N = pos.size();
  N *= 2;
  int cur = 0;
  for (int i = 1; i <= n; i++) {
    st[i] = pos[cur++] * 2;
    en[i] = pos[cur++] * 2;
  }
  cur = 0;
  for (int i = 1; i <= n; i++) {
    khoitao(st[i], en[i], -costt[i], 1, cur);
    cur += 2;
  }
  s = 0;
  t = N + 2;
  for (int i = 0; i < N + 2; i++) {
    khoitao(i, i + 1, 0, m, cur);
    cur += 2;
  }
}
int inq[oo];
int tr[oo];
int d[oo];
bool fp() {
  queue<int> q;
  for (int i = 1; i <= t; i++) {
    inq[i] = 0;
    tr[i] = 0;
    d[i] = inf;
  }
  q.push(s);
  inq[s] = 0;
  d[s] = 0;
  while (!q.empty()) {
    int u = q.front();
    q.pop();
    inq[u] = 0;
    for (int i = 0; i < adj[u].size(); i++) {
      int v = adj[u][i];
      if (cap[v] > f[v]) {
        int uv = cost[v];
        int TT = val[v];
        if (d[TT] > d[u] + uv) {
          tr[TT] = v;
          d[TT] = d[u] + uv;
          if (inq[TT] == 0) {
            inq[TT] = 1;
            q.push(TT);
          }
        }
      }
    }
  }
  return tr[t];
}
int minc;
void IncFlow() {
  int D = inf;
  for (int i = t; i != s;) {
    int u = tr[i];
    D = min(D, cap[u] - f[u]);
    i = val[u ^ 1];
  }
  for (int i = t; i != s;) {
    int u = tr[i];
    f[u] += D;
    f[u ^ 1] -= D;
    i = val[u ^ 1];
  }
  minc += D * d[t];
  maxf += D;
}
void solve() {
  cre();
  while (fp()) IncFlow();
  int tmp = 0;
  for (int i = 1; i <= n; i++) {
    if (f[tmp])
      cout << 1 << " ";
    else
      cout << 0 << " ";
    tmp += 2;
  }
}
void ouput() {}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  if (ifstream("test.txt")) {
    freopen("test.txt", "r", stdin);
  } else if (ifstream(""
                      ".inp")) {
    freopen(
        ""
        ".inp",
        "r", stdin);
    freopen(
        ""
        ".out",
        "w", stdout);
  }
  int t = 1;
  while (t--) {
    input();
    solve();
    ouput();
  }
}
