#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7f7f7f7f;
const long long Inf = 1e18;
const int N = 23;
const int mod = 0;
int gi() {
  int x = 0, o = 1;
  char ch = getchar();
  while ((ch < '0' || ch > '9') && ch != '-') ch = getchar();
  if (ch == '-') o = -1, ch = getchar();
  while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar();
  return x * o;
}
template <typename T>
bool chkmax(T &a, T b) {
  return a < b ? a = b, 1 : 0;
};
template <typename T>
bool chkmin(T &a, T b) {
  return a > b ? a = b, 1 : 0;
};
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
int sub(int a, int b) { return a - b < 0 ? a - b + mod : a - b; }
void inc(int &a, int b) { a = (a + b >= mod ? a + b - mod : a + b); }
void dec(int &a, int b) { a = (a - b < 0 ? a - b + mod : a - b); }
int n, p, f[1 << N], g[1 << N], tim[1 << N];
struct data {
  int s, len, t, id;
} a[N], b[N];
bool cmp1(data a, data b) { return a.s < b.s; }
bool cmp2(data a, data b) { return a.t < b.t; }
pair<int, int> ans[N];
void print(int s, int op) {
  while (s) {
    ans[g[s]].first = op;
    ans[g[s]].second = tim[s];
    s ^= 1 << (g[s] - 1);
  }
}
int main() {
  cin >> n >> p;
  for (int i = 1; i <= n; i++)
    a[i].s = gi(), a[i].len = gi(), a[i].t = gi(), a[i].id = i, b[i] = a[i];
  sort(a + 1, a + n + 1, cmp1);
  sort(b + 1, b + n + 1, cmp2);
  memset(f, 0x7f, sizeof(f));
  f[0] = 1;
  for (int i = 0; i < (1 << n) - 1; i++) {
    if (f[i] == inf) continue;
    int now = 1, t = f[i], jump = 0;
    for (int j = 1; j <= n; j++) {
      if (i >> (b[j].id - 1) & 1) continue;
      while (now <= n && t + b[j].t >= a[now].s) {
        if (!(i >> (a[now].id - 1) & 1)) {
          if (a[now].s <= t && t <= a[now].s + a[now].len - 1)
            t = a[now].s + a[now].len;
        } else {
          t = max(t, a[now].s + a[now].len);
        }
        jump |= 1 << (a[now].id - 1);
        ++now;
      }
      if (jump >> (b[j].id - 1) & 1) continue;
      int s = i | (1 << (b[j].id - 1));
      if (chkmin(f[s], t + b[j].t)) g[s] = b[j].id, tim[s] = t;
    }
  }
  if (p == 1) {
    if (f[(1 << n) - 1] == inf)
      puts("NO");
    else {
      puts("YES");
      print((1 << n) - 1, 1);
      for (int i = 1; i <= n; i++)
        printf("%d %d\n", ans[i].first, ans[i].second);
    }
  } else {
    for (int i = 0; i < (1 << n); i++) {
      int j = ((1 << n) - 1) ^ i;
      if (f[i] != inf && f[j] != inf) {
        puts("YES");
        print(i, 1);
        print(j, 2);
        for (int i = 1; i <= n; i++)
          printf("%d %d\n", ans[i].first, ans[i].second);
        return 0;
      }
    }
    puts("NO");
  }
  return 0;
}
