#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:65777216")
using namespace std;
int n, k;
int s[1111];
int t[1111];
int c[1111];
vector<pair<int, int> > f[2222];
const int inf = 10111111111;
int d[2222];
int from[2222];
struct mcnet {
  vector<vector<pair<int, pair<int, int> > > > a;
  vector<pair<int, pair<int, int> > >::iterator i;
  mcnet(int n) : a(n) {}
  void add(int x, int y, int w, int c = 1) {
    for (i = a[x].begin(); i != a[x].end(); ++i)
      if (i->first == y && i->second.second == w) {
        if (!(i->second.first += c)) *i = a[x].back(), a[x].pop_back();
        return;
      }
    a[x].push_back(make_pair(y, pair<int, int>(c, w)));
  }
  bool hascycle() {
    int aa[4444];
    int n = a.size();
    for (int i(0); i < (n); i++) aa[i] = 0;
    for (int i(0); i < (n); i++)
      for (int j(0); j < (n); j++)
        for (int k(0); k < (a[j].size()); k++)
          aa[a[j][k].first] =
              min(aa[a[j][k].first], aa[j] + a[j][k].second.second);
    for (int j(0); j < (n); j++)
      for (int k(0); k < (a[j].size()); k++)
        if (aa[a[j][k].first] > aa[j] + a[j][k].second.second) return 1;
    if (n > 2000) {
      puts("FUCK");
      return 1;
    }
    return 0;
  }
  pair<int, int> flow(int s, int t, int k) {
    vector<int> p(a.size());
    for (pair<int, int> res; res.first < k;) {
      priority_queue<pair<int, int> > Q;
      vector<int> f(a.size(), -1u / 2), prev(a.size(), -1);
      f[s] = 0, Q.push(pair<int, int>(0, -s));
      for (int x, d; Q.size();) {
        pair<int, int> cur = Q.top();
        Q.pop();
        if (f[x = -cur.second] != (d = -cur.first)) continue;
        for (i = a[x].begin(); i != a[x].end(); ++i) {
          int y = i->first, z = i->second.second;
          if (d + z + p[x] - p[y] < f[y])
            f[y] = d + z + p[x] - p[y], prev[y] = x,
            Q.push(pair<int, int>(-f[y], -y));
        }
      }
      if (prev[t] < 0) return res;
      int flow = 1;
      for (int x, y = t; ~(x = prev[y]); y = x)
        for (i = a[x].begin(); i != a[x].end(); ++i)
          if (i->first == y && f[x] + i->second.second + p[x] == f[y] + p[y])
            flow = min(flow, i->second.first);
      res.first += flow, res.second += (f[t] + p[t] - p[s]) * flow;
      for (int x, y = t; ~(x = prev[y]); y = x)
        add(x, y, f[y] + p[y] - f[x] - p[x], -flow),
            add(y, x, f[x] + p[x] - f[y] - p[y], +flow);
      for (int i(0); i < (a.size()); i++) p[i] += f[i];
    }
  }
};
void floww() {
  for (int i(0); i < (2 * n + 2); i++) d[i] = inf, from[i] = -1;
  d[2 * n] = 0;
  priority_queue<pair<int, int> > q;
  q.push(pair<int, int>(0, 2 * n));
  while (!q.empty()) {
    pair<int, int> x = q.top();
    q.pop();
    int ver = x.second;
    int cost = -x.first;
    if (d[ver] != cost) continue;
    for (int i(0); i < (f[ver].size()); i++) {
      int nw = f[ver][i].first;
      int ncost = cost + f[ver][i].second;
      if (d[nw] > ncost) {
        d[nw] = ncost;
        from[nw] = ver;
        q.push(pair<int, int>(-ncost, nw));
      }
    }
  }
  if (d[2 * n + 1] != inf) {
    int curr = 2 * n + 1;
    while (curr != 2 * n) {
      int prev = from[curr];
      for (int i(0); i < (f[prev].size()); i++)
        if (f[prev][i].first == curr) {
          f[curr].push_back(pair<int, int>(prev, -f[prev][i].second));
          swap(f[prev][i], f[prev].back());
          f[prev].pop_back();
        }
      curr = prev;
    }
  }
}
int main() {
  cin >> n >> k;
  for (int i(0); i < (n); i++) scanf("%d %d %d", s + i, t + i, c + i);
  vector<int> xx;
  xx.push_back(0);
  xx.push_back(2000000000);
  for (int i(0); i < (n); i++) xx.push_back(s[i]);
  for (int i(0); i < (n); i++) xx.push_back(s[i] + t[i]);
  sort((xx).begin(), (xx).end()),
      xx.erase(unique(xx.begin(), xx.end()), xx.end());
  mcnet fl(2 * n + xx.size());
  for (int i(0); i < (n); i++) fl.add(i, i + n, -c[i]);
  for (int j(0); j < (k); j++)
    for (int i(0); i < (xx.size() - 1); i++)
      fl.add(2 * n + i, 2 * n + i + 1, 0);
  for (int i(0); i < (n); i++)
    fl.add(i + n,
           2 * n + lower_bound(xx.begin(), xx.end(), s[i] + t[i]) - xx.begin(),
           0);
  for (int i(0); i < (n); i++)
    fl.add(2 * n + lower_bound(xx.begin(), xx.end(), s[i]) - xx.begin(), i, 0);
  pair<int, int> t = fl.flow(2 * n, 2 * n + xx.size() - 1, k);
  for (int i(0); i < (n); i++) {
    if (i) printf(" ");
    bool use = 0;
    for (int j(0); j < (fl.a[i + n].size()); j++)
      if (fl.a[i + n][j].first == i) use = 1;
    printf("%d", (use ? 1 : 0));
  }
  puts("");
  return 0;
}
