#include <bits/stdc++.h>
using namespace std;
int N, P;
struct Info {
  int s, len, t, id;
  bool operator<(const Info &i) const { return t < i.t; }
};
bool cmp(Info a, Info b) { return a.s < b.s; }
Info info[22], tmp[22];
int dp[1 << 22];
pair<int, int> nxt[1 << 22], sol[22];
vector<pair<int, int> > seg;
int main() {
  scanf("%d %d", &N, &P);
  for (int i = 0; i < N; i++) {
    scanf("%d %d %d", &info[i].s, &info[i].len, &info[i].t);
    info[i].id = i;
    tmp[i] = info[i];
  }
  sort(info, info + N);
  sort(tmp, tmp + N, cmp);
  int s = 1, cnt = 0;
  for (int i = 0; i < N; i++) {
    seg.push_back(pair<int, int>(s, tmp[i].s - 1));
    s = tmp[i].s + tmp[i].len;
  }
  if (P == 1) {
    for (int i = 0; i < (1 << N); i++) dp[i] = 2e9;
    dp[0] = 1;
    for (int i = 0; i < (1 << N); i++) {
      int pos = 0;
      while (pos < seg.size() && seg[pos].second < dp[i]) pos++;
      for (int j = 0; j < N; j++) {
        if (i & (1 << j)) continue;
        while (pos < seg.size() &&
               max(dp[i], seg[pos].first) + info[j].t > seg[pos].second)
          pos++;
        if (pos == seg.size()) continue;
        int t = max(dp[i], seg[pos].first) + info[j].t;
        if (t < info[j].s && dp[i | (1 << j)] > t) {
          dp[i | (1 << j)] = t;
          nxt[i | (1 << j)] = pair<int, int>(j, max(dp[i], seg[pos].first));
        }
      }
    }
    if (dp[(1 << N) - 1] == 2e9)
      printf("NO");
    else {
      printf("YES\n");
      int mask = (1 << N) - 1;
      while (mask) {
        int x = nxt[mask].first;
        int y = nxt[mask].second;
        sol[info[x].id] = pair<int, int>(1, y);
        mask -= (1 << x);
      }
      for (int i = 0; i < N; i++) {
        printf("%d %d\n", sol[i].first, sol[i].second);
      }
    }
  } else {
    for (int i = 0; i < (1 << N); i++) dp[i] = 2e9;
    dp[0] = 1;
    for (int i = 0; i < (1 << N); i++) {
      int pos1 = 0;
      int pos2 = 0;
      while (pos1 < seg.size() && seg[pos1].second < dp[i]) pos1++;
      while (pos1 < seg.size() && seg[pos1].first > seg[pos1].second) pos1++;
      if (pos2 < pos1) pos2 = pos1;
      for (int j = 0; j < N; j++) {
        if (i & (1 << info[j].id)) continue;
        while (pos2 < seg.size() &&
               max(dp[i], seg[pos1].first) + info[j].t > seg[pos2].second) {
          if (i & (1 << tmp[pos2].id)) {
            pos1 = pos2 + 1;
            while (pos1 < seg.size() && seg[pos1].first > seg[pos1].second)
              pos1++, pos2++;
          }
          pos2++;
        }
        if (pos1 == seg.size()) continue;
        int t = max(dp[i], seg[pos1].first) + info[j].t;
        if (t < info[j].s && dp[i | (1 << info[j].id)] > t) {
          dp[i | (1 << info[j].id)] = t;
          nxt[i | (1 << info[j].id)] =
              pair<int, int>(info[j].id, max(dp[i], seg[pos1].first));
        }
      }
    }
    int mn = 2e9, p = -1;
    for (int i = 0; i < (1 << N); i++) {
      if (mn > max(dp[i], dp[((1 << N) - 1) ^ i])) {
        mn = max(dp[i], dp[((1 << N) - 1) ^ i]);
        p = i;
      }
    }
    if (mn == 2e9)
      printf("NO");
    else {
      printf("YES\n");
      int mask = p;
      while (mask) {
        int x = nxt[mask].first;
        int y = nxt[mask].second;
        sol[x] = pair<int, int>(1, y);
        mask -= (1 << x);
      }
      mask = ((1 << N) - 1) ^ p;
      while (mask) {
        int x = nxt[mask].first;
        int y = nxt[mask].second;
        sol[x] = pair<int, int>(2, y);
        mask -= (1 << x);
      }
      for (int i = 0; i < N; i++) {
        printf("%d %d\n", sol[i].first, sol[i].second);
      }
    }
  }
}
