#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int inf = 0x7fffffff;
int n, P;
struct Plan {
  int l, r, t;
  int id;
} a[33];
int b[33], c[33];
bool cmpl(Plan x, Plan y) { return x.l < y.l; }
bool cmpt(int x, int y) { return a[x].t < a[y].t; }
int dp[5000500];
int la[5000500];
int ans[33][2];
void out(int s, int sym) {
  if (!s) return;
  ans[a[la[s]].id][0] = sym;
  ans[a[la[s]].id][1] = dp[s] - a[la[s]].t;
  out(s ^ (1 << la[s]), sym);
}
int main() {
  scanf("%d%d", &n, &P);
  for (int i = 0; i < n; ++i) {
    scanf("%d%d%d", &a[i].l, &a[i].r, &a[i].t);
    a[i].id = i;
    a[i].r += a[i].l - 1;
  }
  sort(a, a + n, cmpl);
  dp[0] = 1;
  int U = (1 << n);
  for (int i = 1; i <= U; ++i) dp[i] = inf;
  int st, v;
  int tb, tc;
  int pa, pb;
  int fl;
  int t;
  int nxt;
  for (int s = 0; s < U; ++s) {
    if (dp[s] == inf) continue;
    st = dp[s];
    tb = 0, tc = 0;
    for (int i = 0; i < n; ++i)
      if ((s >> i) & 1)
        b[++tb] = i;
      else
        c[++tc] = i;
    sort(c + 1, c + tc + 1, cmpt);
    pa = 0, pb = 1;
    for (int i = 1; i <= tc; ++i) {
      v = c[i];
      t = a[v].t;
      fl = 1;
      while (fl) {
        fl = 0;
        while (pa < n && a[pa].l <= st) {
          if (a[pa].r >= st) st = a[pa].r + 1, fl = 1;
          pa++;
        }
        while (pb <= tb && a[b[pb]].l <= st + t) {
          if (st < a[b[pb]].l) st = a[b[pb]].r + 1, fl = 1;
          pb++;
        }
      }
      nxt = (s | (1 << v));
      if (st + t < a[v].l && st + t < dp[nxt]) {
        dp[nxt] = st + t;
        la[nxt] = v;
      }
    }
  }
  fl = 0;
  if (P == 1 && dp[U - 1] != inf)
    fl = 1, out(U - 1, 1);
  else if (P == 2) {
    U--;
    for (int i = 0; i <= U; ++i)
      if (dp[i] != inf && dp[U ^ i] != inf) {
        fl = 1;
        out(i, 1);
        out(U ^ i, 2);
        break;
      }
  }
  if (!fl) {
    puts("NO");
    return 0;
  }
  puts("YES");
  for (int i = 0; i < n; ++i) printf("%d %d\n", ans[i][0], ans[i][1]);
  return 0;
}
