#include <bits/stdc++.h>
using namespace std;
int read() {
  int g = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    g = g * 10 + ch - '0';
    ch = getchar();
  }
  return g * f;
}
const int N = 25;
const long long INF = 1e18;
long long dp[1 << 22], Ansr[N];
int Ansl[N], pre[1 << 22], n, p, tot1, tot2, b[N], c[N];
struct node {
  int l, r, t, id;
  bool operator<(const node& oth) const { return l < oth.l; }
} a[N];
bool cmp(int x, int y) { return a[x].t < a[y].t; }
void dfs(int s, int now) {
  if (!s) return void();
  int ps = pre[s];
  Ansr[a[ps].id] = dp[s] - a[ps].t;
  Ansl[a[ps].id] = now;
  dfs(s ^ (1 << ps - 1), now);
}
signed main() {
  n = read(), p = read();
  for (int i = (1); i <= (n); i++) {
    int l = read(), x = read(), t = read();
    a[i] = node{l, l + x - 1, t, i};
  }
  sort(a + 1, a + n + 1);
  int maxn = (1 << n) - 1;
  for (int i = (0); i <= (maxn); i++) dp[i] = INF;
  dp[0] = 1;
  for (int i = (0); i <= (maxn); i++)
    if (dp[i] != INF) {
      tot1 = tot2 = 0;
      for (int j = (1); j <= (n); j++)
        if (!(i & (1 << j - 1)))
          b[++tot1] = j;
        else
          c[++tot2] = j;
      sort(b + 1, b + tot1 + 1, cmp);
      int p1 = 1, p2 = 1;
      long long las = dp[i];
      for (int j = (1); j <= (tot1); j++) {
        int now = b[j];
        while (true) {
          bool flag = 0;
          if (p1 <= n && las >= a[p1].l) {
            las = max(las, (long long)a[p1].r + 1);
            p1++, flag = 1;
          }
          while (p2 < tot2 && las > a[c[p2]].l) p2++;
          if (las <= a[c[p2]].l && p2 <= tot2) {
            int x = c[p2];
            if (a[x].l <= las + a[now].t)
              las = max(las, (long long)a[x].r + 1), p2++, flag = 1;
          }
          if (!flag) break;
        }
        int s = i ^ (1 << now - 1);
        if (las + a[now].t < a[now].l && las + a[now].t < dp[s])
          dp[s] = las + a[now].t, pre[s] = now;
      }
    }
  if (p == 1) {
    if (dp[maxn] ^ INF) {
      dfs(maxn, 1);
      puts("YES");
      for (int i = (1); i <= (n); i++)
        cout << Ansl[i] << ' ' << Ansr[i] << '\n';
    } else
      puts("NO");
  } else {
    for (int i = (0); i <= (maxn); i++)
      if (dp[i] != INF && dp[maxn ^ i] != INF) {
        dfs(i, 1);
        dfs(maxn ^ i, 2);
        puts("YES");
        for (int i = (1); i <= (n); i++)
          cout << Ansl[i] << ' ' << Ansr[i] << '\n';
        return signed();
      }
    puts("NO");
  }
  return signed();
}
