#include <bits/stdc++.h>
static constexpr int NONE = -1;
static constexpr int INF = 1000 * 1000;
struct Edge {
  int from;
  int to;
  int flow;
  int capacity;
  int cost;
  int id;
};
struct Task {
  int id;
  int begin;
  int len;
  int cost;
};
int count_vertexes = 0;
int count_edges = 0;
int source = 0;
int sink = 0;
int n = 0, k = 0;
std::vector<int> dist;
std::vector<int> from;
std::vector<int> head;
std::vector<int> next;
std::vector<Edge> edges;
void add_edge(int vertex, Edge edge) {
  edges.push_back(edge);
  int current = edges.size() - 1;
  next[current] = head[vertex];
  head[vertex] = current;
}
void make_edge(int start, int finish, int capacity, int cost, int id) {
  Edge edge = {start, finish, 0, capacity, cost, id};
  Edge rev_edge = {finish, start, 0, 0, -cost, NONE};
  add_edge(start, edge);
  add_edge(finish, rev_edge);
}
bool ford_bellman() {
  std::fill(dist.begin(), dist.end(), INF);
  std::fill(from.begin(), from.end(), NONE);
  dist[source] = 0;
  bool flag = true;
  while (flag) {
    flag = false;
    for (int id = 0; id < edges.size(); id++) {
      Edge edge = edges[id];
      if (edge.flow < edge.capacity &&
          dist[edge.from] + edge.cost < dist[edge.to]) {
        dist[edge.to] = dist[edge.from] + edge.cost;
        from[edge.to] = id;
        flag = true;
      }
    }
  }
  return dist[sink] != INF;
}
void min_cost_k_flow() {
  while (k > 0 && ford_bellman()) {
    for (int cur = from[sink]; cur != NONE; cur = from[edges[cur].from]) {
      edges[cur].flow += 1;
      edges[cur ^ 1].flow -= 1;
    }
    k -= 1;
  }
}
int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  std::cin >> n >> k;
  count_vertexes = 2 * n;
  count_edges = 3 * n;
  dist.resize(count_vertexes, INF);
  from.resize(count_vertexes, NONE);
  head.resize(count_vertexes, NONE);
  next.resize(2 * count_edges, NONE);
  std::vector<int> events;
  std::vector<Task> tasks;
  for (int id = 0; id < n; id++) {
    int begin = 0, len = 0, cost = 0;
    std::cin >> begin >> len >> cost;
    tasks.push_back({id, begin, len, cost});
    events.push_back(begin);
    events.push_back(begin + len);
  }
  std::sort(events.begin(), events.end());
  std::unordered_map<int, int> get;
  get[events[0]] = 0;
  for (int i = 1; i < events.size(); i++) {
    if (events[i - 1] == events[i]) {
      continue;
    }
    get[events[i]] = get.size();
  }
  for (const auto &task : tasks) {
    int start = get[task.begin];
    int finish = get[task.begin + task.len];
    make_edge(start, finish, 1, -task.cost, task.id);
  }
  for (int i = 0; i < get.size() - 1; i++) {
    make_edge(i, i + 1, k, 0, NONE);
  }
  source = 0;
  sink = get.size() - 1;
  min_cost_k_flow();
  std::vector<int> answer(n);
  for (int i = 0; i < n; i++) {
    answer[edges[2 * i].id] = (edges[2 * i].flow == edges[2 * i].capacity);
  }
  for (auto e : answer) {
    std::cout << e << ' ';
  }
  std::cout << '\n';
  return 0;
}
