#include <bits/stdc++.h>
using namespace std;
class SuccessiveShortestPath {
 public:
  class MinCostMaxFlowEdge {
   public:
    MinCostMaxFlowEdge(int destination, long long capacity, long long cost) {
      this->destination_ = destination;
      this->capacity_ = capacity;
      this->cost_ = cost;
      this->flow_ = 0L;
    }
    MinCostMaxFlowEdge(MinCostMaxFlowEdge& ref) {
      this->destination_ = ref.destination_;
      this->capacity_ = ref.capacity_;
      this->cost_ = ref.cost_;
      this->flow_ = ref.flow_;
    }
    int destination_;
    long long capacity_;
    long long cost_;
    long long flow_;
  };
  vector<vector<MinCostMaxFlowEdge*> > adj_;
  vector<long long> supply_;
  SuccessiveShortestPath(int node_count) {
    supply_ = vector<long long>(node_count, 0LL);
    adj_ = vector<vector<MinCostMaxFlowEdge*> >(node_count,
                                                vector<MinCostMaxFlowEdge*>());
  }
  void addEdge(int from, int to, long long capacity, long long cost) {
    adj_[from].push_back(new MinCostMaxFlowEdge(to, capacity, cost));
  }
  void setSupply(int node, long long amount) { supply_[node] = amount; }
  long long solve(int* is_infeasible) {
    *is_infeasible = 0;
    int n = ((int)(supply_).size());
    vector<vector<MinCostMaxFlowEdge*> > adjcopy = adj_;
    for (int i = 0; i < ((int)(adj_).size()); ++i) {
      for (int j = 0; j < ((int)(adj_[i]).size()); ++j) {
        adjcopy[i][j] = new MinCostMaxFlowEdge(*(adj_[i][j]));
      }
    }
    vector<vector<MinCostMaxFlowEdge*> > reverse_adj(
        n, vector<MinCostMaxFlowEdge*>());
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < ((int)(adjcopy[i]).size()); ++j) {
        reverse_adj[i].push_back(NULL);
      }
    }
    vector<long long> supply_cpy = supply_;
    for (int i = 0; i < n; ++i) {
      int sigma = ((int)(adjcopy[i]).size());
      for (int j = 0; j < sigma; ++j) {
        if (reverse_adj[i][j] == NULL) {
          int destination = adjcopy[i][j]->destination_;
          long long cost = adjcopy[i][j]->cost_;
          MinCostMaxFlowEdge* new_edge = new MinCostMaxFlowEdge(i, 0, -cost);
          adjcopy[destination].push_back(new_edge);
          reverse_adj[destination].push_back(adjcopy[i][j]);
          reverse_adj[i][j] = new_edge;
          if (cost < 0LL) {
            adjcopy[i][j]->flow_ = adjcopy[i][j]->capacity_;
            reverse_adj[i][j]->flow_ = -adjcopy[i][j]->capacity_;
            supply_cpy[i] -= adjcopy[i][j]->capacity_;
            supply_cpy[adjcopy[i][j]->destination_] += adjcopy[i][j]->capacity_;
          }
        }
      }
    }
    int tap = n;
    int sink = n + 1;
    adjcopy.push_back(vector<MinCostMaxFlowEdge*>());
    adjcopy.push_back(vector<MinCostMaxFlowEdge*>());
    reverse_adj.push_back(vector<MinCostMaxFlowEdge*>());
    reverse_adj.push_back(vector<MinCostMaxFlowEdge*>());
    long long flow_snd = 0LL;
    long long flow_rcv = 0LL;
    for (int i = 0; i < n; ++i) {
      if (supply_cpy[i] > 0LL) {
        flow_snd += supply_cpy[i];
        MinCostMaxFlowEdge* fwd = new MinCostMaxFlowEdge(i, supply_cpy[i], 0LL);
        MinCostMaxFlowEdge* bck = new MinCostMaxFlowEdge(tap, 0, 0LL);
        adjcopy[tap].push_back(fwd);
        reverse_adj[tap].push_back(bck);
        adjcopy[i].push_back(bck);
        reverse_adj[i].push_back(fwd);
      } else if (supply_cpy[i] < 0LL) {
        flow_rcv += -supply_cpy[i];
        MinCostMaxFlowEdge* fwd =
            new MinCostMaxFlowEdge(sink, -supply_cpy[i], 0LL);
        MinCostMaxFlowEdge* bck = new MinCostMaxFlowEdge(i, 0, 0LL);
        adjcopy[i].push_back(fwd);
        reverse_adj[i].push_back(bck);
        adjcopy[sink].push_back(bck);
        reverse_adj[sink].push_back(fwd);
      }
    }
    if (flow_snd != flow_rcv) {
      *is_infeasible = 1;
      return -13LL;
    }
    vector<long long> pi(n + 2, 0LL);
    vector<int> pred(n + 2, 0), pred_adj(n + 2, 0);
    vector<long long> shortest(n + 2, 0LL);
    set<pair<long long, int> > pq;
    long long total_flow = 0LL;
    while (true) {
      pq.insert(make_pair(0LL, tap));
      for (int i = 0; i < n + 2; ++i) {
        shortest[i] = -1LL;
      }
      shortest[tap] = 0LL;
      while (!pq.empty()) {
        long long dist = pq.begin()->first;
        int node = pq.begin()->second;
        pq.erase(pq.begin());
        if (shortest[node] != dist) continue;
        for (int i = 0; i < ((int)(adjcopy[node]).size()); ++i) {
          MinCostMaxFlowEdge* ed = adjcopy[node][i];
          if (ed->capacity_ - ed->flow_ <= 0LL) {
            continue;
          }
          int dest = ed->destination_;
          long long new_dist = dist + ed->cost_ - pi[node] + pi[dest];
          assert(new_dist >= dist);
          if (shortest[dest] == -1LL || shortest[dest] > new_dist) {
            shortest[dest] = new_dist;
            pq.insert(make_pair(new_dist, dest));
            pred[dest] = node;
            pred_adj[dest] = i;
          }
        }
      }
      if (shortest[sink] == -1LL) {
        break;
      }
      for (int j = 0; j < n + 2; ++j) {
        if (shortest[j] != -1LL) {
          pi[j] = pi[j] - shortest[j];
        }
      }
      vector<int> nodes;
      vector<int> go_next;
      nodes.push_back(sink);
      go_next.push_back(-1);
      while (nodes.back() != tap) {
        go_next.push_back(pred_adj[nodes.back()]);
        nodes.push_back(pred[nodes.back()]);
      }
      reverse(nodes.begin(), nodes.end());
      reverse(go_next.begin(), go_next.end());
      long long flow = flow_snd;
      for (int(i) = 0; (i) < (((int)(nodes).size()) - 1); ++(i))
        flow = min((flow), (adjcopy[nodes[i]][go_next[i]]->capacity_ -
                            adjcopy[nodes[i]][go_next[i]]->flow_));
      total_flow += flow;
      for (int(i) = 0; (i) < (((int)(nodes).size()) - 1); ++(i)) {
        adjcopy[nodes[i]][go_next[i]]->flow_ += flow;
        reverse_adj[nodes[i]][go_next[i]]->flow_ -= flow;
      }
    }
    if (total_flow != flow_snd) {
      *is_infeasible = 1;
      return 0LL;
    }
    long long answer = 0LL;
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < ((int)(adj_[i]).size()); ++j) {
        adj_[i][j]->flow_ = adjcopy[i][j]->flow_;
        answer += adj_[i][j]->flow_ * adj_[i][j]->cost_;
      }
    }
    return answer;
  }
};
int stat[1200];
int en[1200];
int pro[1200];
int ret[1200];
int sid[1200];
int sen[1200];
map<int, int> waktu;
int id = 1;
void Put(int w) {
  if (waktu.count(w)) return;
  waktu[w] = id;
  ++id;
}
int main() {
  int n, k;
  cin >> n >> k;
  for (int(i) = 0; (i) < (n); ++(i)) {
    cin >> stat[i] >> en[i] >> pro[i];
    en[i] = stat[i] + en[i];
    Put(stat[i]);
    Put(en[i]);
    sid[i] = waktu[stat[i]];
    sen[i] = waktu[en[i]];
  }
  SuccessiveShortestPath mcmf(((int)(waktu).size()) + 2);
  int sink = ((int)(waktu).size()) + 1;
  assert(id == sink);
  int tap = 0;
  vector<pair<int, int> > ws;
  ws.push_back(make_pair(-1, tap));
  ws.push_back(make_pair(2012012012, sink));
  for (typeof((waktu).begin()) it = (waktu).begin(); it != (waktu).end();
       it++) {
    ws.push_back(make_pair(it->first, it->second));
  }
  sort(ws.begin(), ws.end());
  for (int(i) = 0; (i) < (((int)(ws).size()) - 1); ++(i))
    mcmf.addEdge(ws[i].second, ws[i + 1].second, 55, 0);
  for (int(i) = 0; (i) < (n); ++(i)) {
    int ids = waktu[stat[i]];
    int ide = waktu[en[i]];
    mcmf.addEdge(ids, ide, 1, -pro[i]);
  }
  mcmf.setSupply(tap, k);
  mcmf.setSupply(sink, -k);
  int f = 0;
  mcmf.solve(&f);
  assert(!f);
  for (int(i) = 0; (i) < (((int)(waktu).size()) + 2); ++(i))
    for (int(j) = 0; (j) < (((int)(mcmf.adj_[i]).size())); ++(j)) {
      if (mcmf.adj_[i][j]->cost_ < 0LL && mcmf.adj_[i][j]->flow_) {
        int a = i;
        int b = mcmf.adj_[i][j]->destination_;
        int cos = mcmf.adj_[i][j]->cost_ * -1;
        for (int(kk) = 0; (kk) < (n); ++(kk))
          if (!ret[kk] && sid[kk] == a && sen[kk] == b && pro[kk] == cos) {
            ret[kk] = 1;
            break;
          }
      }
    }
  for (int(i) = 0; (i) < (n); ++(i)) {
    if (i) cout << " ";
    cout << ret[i];
  }
  cout << endl;
}
