#include <bits/stdc++.h>
struct edge_t {
  int u, v, cap, cost, flow;
  edge_t(int U, int V, int ca, int co)
      : u(U), v(V), cap(ca), cost(co), flow(0) {}
};
struct task_t {
  int start, time, profit;
  task_t() : start(0), time(0), profit(0) {}
  task_t(int start, int time, int profit)
      : start(start), time(time), profit(profit) {}
};
const int INF = 2000000000;
std::vector<int> phi, dist, p;
std::vector<edge_t> e;
std::vector<std::vector<int> > g;
int n;
void add_edge(int u, int v, int cost, int cap) {
  g[u].push_back(e.size());
  e.push_back(edge_t(u, v, cap, cost));
  g[v].push_back(e.size());
  e.push_back(edge_t(v, u, 0, -cost));
}
void bellman_ford(int s) {
  std::fill(phi.begin(), phi.end(), INF);
  phi[s] = 0;
  for (int k = 0; k < n; k++)
    for (unsigned int i = 0; i < e.size(); i++)
      if (phi[e[i].v] > phi[e[i].u] + e[i].cost && e[i].cap > 0)
        phi[e[i].v] = phi[e[i].u] + e[i].cost;
}
bool dijkstra(int s, int t) {
  std::vector<int> used(n, 0);
  std::fill(dist.begin(), dist.end(), INF);
  std::fill(p.begin(), p.end(), -1);
  dist[s] = 0;
  while (true) {
    int v = -1;
    for (int i = 0; i < n; i++)
      if (!used[i] && (v == -1 || dist[v] > dist[i])) v = i;
    if (v == -1 || dist[v] == INF) break;
    used[v] = 1;
    for (int i = 0; i < (int)g[v].size(); i++) {
      int to = g[v][i];
      int u = e[to].v, cost = e[to].cost;
      if (e[to].cap - e[to].flow <= 0) continue;
      if (dist[u] > dist[v] + phi[v] - phi[u] + cost) {
        dist[u] = dist[v] + phi[v] - phi[u] + cost;
        p[u] = to;
      }
    }
  }
  return dist[t] < INF;
}
void mincost_maxflow(int s, int t) {
  bellman_ford(s);
  while (dijkstra(s, t)) {
    for (int i = 0; i < n; i++) phi[i] += dist[i];
    int add_stream = INF, k = 0;
    for (int v = t; v != s; k = p[v], v = e[k].u)
      add_stream = std::min(add_stream, e[k].cap - e[k].flow);
    for (int v = t; v != s; k = p[v], v = e[k].u) {
      e[k].flow += add_stream;
      e[k ^ 1].flow -= add_stream;
    }
  }
}
int main(int argc, char** argv) {
  int tasks_count, automats_count;
  std::cin >> tasks_count >> automats_count;
  std::vector<int> time;
  std::vector<task_t> tasks;
  time.push_back(0);
  time.push_back(INF);
  for (int i = 0; i < tasks_count; ++i) {
    struct task_t task;
    std::cin >> task.start >> task.time >> task.profit;
    tasks.push_back(task);
    time.push_back(task.start);
  }
  std::sort(time.begin(), time.end());
  time.erase(std::unique(time.begin(), time.end()), time.end());
  n = time.size();
  phi.resize(n);
  dist.resize(n);
  p.resize(n);
  g.resize(n);
  for (int i = 0; i < n - 1; ++i) add_edge(i, i + 1, 0, automats_count);
  for (int i = 0; i < tasks_count; i++) {
    int from =
        (int)(std::lower_bound(time.begin(), time.end(), tasks[i].start) -
              time.begin());
    int to = (int)(std::lower_bound(time.begin(), time.end(),
                                    tasks[i].start + tasks[i].time) -
                   time.begin());
    add_edge(from, to, -tasks[i].profit, 1);
  }
  mincost_maxflow(0, n - 1);
  for (unsigned int i = 0; i < e.size(); i += 2)
    if (e[i].cost < 0) std::cout << (e[i].flow > 0 ? "1" : "0") << " ";
  return 0;
}
