#include <bits/stdc++.h>
const int inf = 2100000000;
int N, P;
struct item {
  int id, s, len, t;
  bool operator<(const item& it) const { return s < it.s; }
} a[22];
int b[22], f[1 << 22], ty[22], t[22];
bool cmp(int i, int j) { return a[i].t < a[j].t; }
char g[1 << 22];
int max(int a, int b) { return a > b ? a : b; }
int min(int a, int b) { return a < b ? a : b; }
bool cmin(int& a, int b) { return b < a ? a = b, 1 : 0; }
void chk(int id, int S) {
  while (S) {
    int i = g[S];
    ty[a[i].id] = id;
    t[a[i].id] = f[S] - a[i].t;
    S -= 1 << i;
  }
}
int l[23], r[23];
int main() {
  scanf("%d%d", &N, &P);
  for (int i = 0; i < N; i++)
    scanf("%d%d%d", &a[i].s, &a[i].len, &a[i].t), a[i].id = b[i] = i;
  std::sort(a, a + N);
  std::sort(b, b + N, cmp);
  for (int S = *f = 1; S < 1 << N; S++) f[S] = inf;
  int counter = 0;
  for (int S = 0; S + 1 < 1 << N; S++)
    if (f[S] < inf) {
      int cnt = 0, s = f[S];
      for (int i = 0; i < N; i++) {
        counter++;
        if (a[i].s <= s)
          s = max(s, a[i].s + a[i].len);
        else if (S >> i & 1)
          l[cnt] = s, r[cnt++] = a[i].s, s = a[i].s + a[i].len;
      }
      l[cnt] = s;
      r[cnt] = inf;
      for (int i = 0, j = 0; j < N; j++)
        if (!(S >> b[j] & 1)) {
          while (i < cnt && l[i] >= r[i] - a[b[j]].t) i++;
          if (l[i] < min(r[i], a[b[j]].s) - a[b[j]].t &&
              cmin(f[S | 1 << b[j]], l[i] + a[b[j]].t))
            g[S | 1 << b[j]] = b[j];
        }
    }
  bool fl = 0;
  int U = (1 << N) - 1;
  if (P == 1) {
    if (fl = (f[U] < inf)) chk(1, U);
  } else
    for (int S = 0; S < 1 << N && !fl; S++)
      if (f[S] < inf && f[U - S] < inf) fl = 1, chk(1, S), chk(2, U - S);
  if (fl) {
    puts("YES");
    for (int i = 0; i < N; i++) printf("%d %d\n", ty[i], t[i]);
  } else
    puts("NO");
}
