#include <bits/stdc++.h>
using namespace std;
const int N = 22, inf = 0x3f3f3f3f;
struct data {
  int l, r, len, id;
  data(int l = 0, int r = 0, int len = 0, int id = 0)
      : l(l), r(r), len(len), id(id) {}
  bool operator<(const data& a) const { return l < a.l; }
} a[N];
int n, K, f[1 << N], bl[1 << N], ans[N][2];
void upd(int x, int y) {
  for (; x; x -= 1 << bl[x]) {
    ans[a[bl[x]].id][0] = y;
    ans[a[bl[x]].id][1] = f[x] - a[bl[x]].len;
  }
}
void output() {
  cout << "YES\n";
  for (int i = 0; i < n; ++i) cout << ans[i][0] << ' ' << ans[i][1] << '\n';
  exit(0);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> K;
  for (int i = 0; i < n; ++i)
    cin >> a[i].l >> a[i].r >> a[i].len, a[i].id = i, a[i].r += a[i].l - 1;
  sort(a, a + n);
  memset(f, 0x3f, sizeof f);
  f[0] = 1;
  for (int i = 1; i < (1 << n); ++i) {
    for (int j = 0; j < n; ++j)
      if (i >> j & 1) {
        int tmp = f[i - (1 << j)], len = a[j].len;
        for (int k = 0; k < n; ++k)
          if ((a[k].l <= tmp && tmp <= a[k].r) ||
              (tmp < a[k].l && tmp + len >= a[k].l && (i >> k & 1)))
            tmp = a[k].r + 1;
        tmp += len;
        if (a[j].l > tmp && f[i] > tmp) f[i] = tmp, bl[i] = j;
      }
  }
  if (K == 1) {
    if (f[(1 << n) - 1] < inf) {
      upd((1 << n) - 1, 1);
      output();
    }
    cout << "NO\n";
  } else {
    for (int i = 0; i < (1 << n); ++i)
      if (f[i] < inf && f[(1 << n) - 1 - i] < inf) {
        upd(i, 1);
        upd((1 << n) - 1 - i, 2);
        output();
      }
    cout << "NO\n";
  }
  return 0;
}
