#include <bits/stdc++.h>
using namespace std;
struct trip {
  int l, r, t, id;
} t[25];
int n, p, dp[4200007], pre[4200007], inf, in[25], ch[25], a, b;
pair<int, int> res[25];
int read() {
  int num = 0;
  char c = getchar();
  while (c < '0' || c > '9') c = getchar();
  while (c >= '0' && c <= '9') num = num * 10 + c - '0', c = getchar();
  return num;
}
int cmpl(trip a, trip b) { return a.l < b.l; }
int cmpt(int a, int b) { return t[a].t < t[b].t; }
int gans(int i, int p) {
  if (!i) return 0;
  res[t[pre[i]].id].first = p;
  res[t[pre[i]].id].second = dp[i] - t[pre[i]].t;
  gans(i ^ (1 << pre[i]), p);
  return 0;
}
int main() {
  n = read();
  p = read();
  for (int i = 0; i < n; i++) {
    t[i].l = read();
    t[i].r = read() + t[i].l - 1;
    t[i].t = read();
    t[i].id = i;
  }
  sort(t, t + n, cmpl);
  memset(dp, 0x3f, sizeof dp);
  dp[0] = 1;
  inf = dp[1];
  for (int i = 0; i < (1 << n); i++) {
    if (dp[i] == inf) continue;
    a = b = 0;
    for (int j = 0; j < n; j++)
      if ((i >> j) & 1)
        in[a++] = j;
      else
        ch[b++] = j;
    sort(ch, ch + b, cmpt);
    int pos = 0, posa = 0;
    int lst = dp[i];
    for (int j = 0; j < b; j++) {
      while (1) {
        bool is = 0;
        while (pos < n && t[pos].l <= lst) {
          if (lst <= t[pos].r) lst = t[pos].r + 1, is = 1;
          pos++;
        }
        while (posa < a && lst + t[ch[j]].t >= t[in[posa]].l) {
          if (lst < t[in[posa]].l) lst = t[in[posa]].r + 1, is = 1;
          posa++;
        }
        if (!is) break;
      }
      if (lst + t[ch[j]].t >= t[ch[j]].l) continue;
      if (dp[i | (1 << ch[j])] > lst + t[ch[j]].t) {
        dp[i | (1 << ch[j])] = lst + t[ch[j]].t;
        pre[i | (1 << ch[j])] = ch[j];
      }
    }
    for (int j = 0; j < n; j++)
      if ((i >> j) & 1) in[j] = 0;
  }
  bool ok = 0;
  if (p == 1) {
    if (dp[(1 << n) - 1] != inf) gans((1 << n) - 1, 1), ok = 1;
  } else {
    for (int i = 0; i < (1 << n) && !ok; i++)
      if (dp[i] != inf && dp[((1 << n) - 1) ^ i] != inf)
        gans(i, 1), gans(((1 << n) - 1) ^ i, 2), ok = 1;
  }
  if (ok) {
    cout << "YES" << endl;
    for (int i = 0; i < n; i++)
      cout << res[i].first << ' ' << res[i].second << endl;
  } else
    cout << "NO" << endl;
  return 0;
}
