#include <bits/stdc++.h>
using namespace std;
const int N = 22;
using pii = pair<int, int>;
int n, m, f[1 << N], len[N], st[N], nd[N], tim[N], id[N], g[1 << N], lg[1 << N];
pii pre[N];
struct Node {
  int p, id;
} p[N];
pii gt[1 << N];
inline int lowbit(int x) { return x & -x; }
int main() {
  ios::sync_with_stdio(false);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> st[i] >> len[i] >> tim[i];
    nd[i] = st[i] + len[i] - 1;
    id[i] = i;
    p[i] = {st[i], i};
  }
  sort(id, id + n, [](int x, int y) { return tim[x] < tim[y]; });
  sort(p, p + n, [](Node a, Node b) { return a.p < b.p; });
  memset(f, 63, sizeof(f));
  const int INF = f[0];
  f[0] = g[0] = 1;
  for (int i = 2; i < (1 << n); i++) lg[i] = lg[i >> 1] + 1;
  for (int s = 1; s < (1 << n); s++) {
    int cur = lg[lowbit(s)];
    g[s] = g[s ^ lowbit(s)];
    for (int i = 0; i < n; i++) {
      if (i == cur) continue;
      if ((s & (1 << i)) && !(nd[cur] < st[i] || st[cur] > nd[i])) g[s] = 0;
    }
  }
  for (int s = 0; s < (1 << n) - 1; s++)
    if (f[s] != INF) {
      int lp = 0, ptr = 0, mx = 0;
      while (lp < n && (!((s >> p[lp].id) & 1) || p[lp].p < f[s])) ++lp;
      while (ptr < n && p[ptr].p <= f[s]) mx = max(mx, nd[p[ptr++].id]);
      int t = f[s];
      for (int o = 0; o < n; o++) {
        int c = id[o];
        if (!(s & (1 << c)) && g[s | (1 << c)]) {
          while ((lp < n && p[lp].p <= t + tim[c]) || mx >= t) {
            if (mx >= t) t = mx + 1;
            if (lp < n && p[lp].p <= t + tim[c]) t = max(t, nd[p[lp].id] + 1);
            while (lp < n && (!((s >> p[lp].id) & 1) || p[lp].p < t)) ++lp;
            while (ptr < n && p[ptr].p <= t) mx = max(mx, nd[p[ptr++].id]);
          }
          if (st[c] > t + tim[c]) {
            if (f[s | (1 << c)] > t + tim[c])
              f[s | (1 << c)] = t + tim[c], pre[s | (1 << c)] = {t, c};
          }
        }
      }
    }
  int ss = -1, ans = INF, lim = (1 << n) - 1;
  if (m == 1)
    ans = f[lim], ss = lim;
  else
    for (int s = 0; s <= lim; s++)
      if (ans > max(f[s], f[lim - s])) ans = max(f[s], f[lim - s]), ss = s;
  if (ans == INF) {
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  int tt = lim - ss;
  while (ss) gt[pre[ss].second] = {1, pre[ss].first}, ss -= 1 << pre[ss].second;
  while (tt) gt[pre[tt].second] = {2, pre[tt].first}, tt -= 1 << pre[tt].second;
  for (int i = 0; i < n; i++)
    cout << gt[i].first << ' ' << gt[i].second << endl;
  return 0;
}
