#include <bits/stdc++.h>
using namespace std;
const int MAXN = 23;
const int BIT = (1 << MAXN);
int dp[BIT];
int par[BIT];
int st[MAXN], len[MAXN], ti[MAXN];
int inf = 1e9 + 10;
int pass[MAXN], sol[MAXN];
int ve[MAXN];
void rek(int x, int t) {
  while (x) {
    int y = par[x];
    sol[y] = dp[x] - ti[y];
    pass[y] = t;
    x ^= (1 << y);
  }
  return;
}
bool cmp(int a, int b) { return st[a] < st[b]; }
int main() {
  ios_base::sync_with_stdio(false);
  int n, p;
  cin >> n >> p;
  for (int i = (0); i < (n); ++i) cin >> st[i] >> len[i] >> ti[i];
  for (int i = (0); i < (n); ++i) ve[i] = i;
  sort(ve, ve + n, cmp);
  dp[0] = 1;
  for (int bit = (1); bit < ((1 << n)); ++bit) {
    dp[bit] = inf;
    for (int i = (0); i < (n); ++i) {
      if (!(bit & (1 << i)) || dp[bit ^ (1 << i)] >= inf) continue;
      int ma = bit ^ (1 << i);
      int tr = dp[ma] + ti[i];
      for (int j = (0); j < (n); ++j) {
        int x = ve[j];
        int a = st[x], b = st[x] + len[x] - 1;
        if (bit & (1 << x)) {
          if (tr < a) break;
          if (a <= tr && tr - ti[i] <= b) {
            tr = b + 1 + ti[i];
          }
        } else {
          if (a <= tr - ti[i] && tr - ti[i] <= b) {
            tr = b + 1 + ti[i];
          }
        }
        if (tr >= st[i]) {
          tr = inf;
          break;
        }
      }
      if (dp[bit] > tr) {
        dp[bit] = tr;
        par[bit] = i;
      }
    }
  }
  if (p == 1) {
    if (dp[(1 << n) - 1] == inf)
      cout << "NO\n";
    else {
      cout << "YES\n";
      rek((1 << n) - 1, 1);
      for (int i = (0); i < (n); ++i) cout << pass[i] << " " << sol[i] << "\n";
    }
  } else {
    for (int i = (0); i < ((1 << n)); ++i) {
      if (max(dp[i], dp[(1 << n) - 1 - i]) != inf) {
        rek(i, 1);
        rek((1 << n) - 1 - i, 2);
        cout << "YES\n";
        for (int i = (0); i < (n); ++i)
          cout << pass[i] << " " << sol[i] << "\n";
        return 0;
      }
    }
    cout << "NO\n";
  }
  return 0;
}
