#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 22;
struct Trip {
  long long l, r, t;
  int id;
};
bool operator<(const Trip &a, const Trip &b) { return a.l < b.l; }
int n, npass;
Trip trip[MAXN];
pair<int, int> ans[MAXN];
pair<long long, int> byt[MAXN];
long long dp[1 << MAXN];
pair<int, int> act[1 << MAXN];
void rec(int mask, int cpass) {
  while (mask != 0) {
    int i = act[mask].first;
    ans[trip[i].id] = make_pair(cpass, act[mask].second);
    mask -= 1 << i;
  }
}
bool upd(int mask, long long val, int i, int l) {
  if (val >= dp[mask]) return false;
  dp[mask] = val, act[mask] = make_pair(i, l);
  return true;
}
bool solve() {
  sort(trip, trip + n);
  for (int i = (0); i < (n); ++i) byt[i] = make_pair(trip[i].t, i);
  sort(byt, byt + n);
  for (int i = (0); i < (1 << n); ++i)
    dp[i] = LLONG_MAX, act[i] = make_pair(-2, -2);
  dp[0] = 0, act[0] = make_pair(-1, -1);
  for (int mask = (0); mask < (1 << n); ++mask)
    if (dp[mask] != LLONG_MAX) {
      int at = 0;
      long long l = dp[mask];
      if (l % 2 == 0) ++l;
      long long r = l;
      for (int i = (0); i < (n); ++i) {
        int cur = byt[i].second;
        if (mask & (1 << cur)) continue;
        r = max(r, l + trip[cur].t);
        while (at < n && r > trip[at].l) {
          if ((mask & (1 << at)) != 0 || l > trip[at].l) {
            l = max(l, trip[at].r + 1);
            r = max(r, l + trip[cur].t);
          } else {
            r = max(r, trip[at].r);
          }
          ++at;
        }
        if (r > trip[cur].l) continue;
        if (upd(mask | (1 << cur), r, cur, (l + 1) / 2)) {
        }
      }
    }
  if (npass == 1) {
    if (dp[(1 << n) - 1] != LLONG_MAX) {
      rec((1 << n) - 1, 1);
      return true;
    }
  } else {
    for (int i = (0); i < (1 << n); ++i)
      if (dp[i] != LLONG_MAX && dp[(1 << n) - 1 - i] != LLONG_MAX) {
        rec(i, 1);
        rec((1 << n) - 1 - i, 2);
        return true;
      }
  }
  return false;
}
void run() {
  scanf("%d%d", &n, &npass);
  for (int i = (0); i < (n); ++i) {
    int len;
    scanf("%lld%d%lld", &trip[i].l, &len, &trip[i].t);
    --trip[i].l, trip[i].l *= 2, trip[i].r = trip[i].l + 2 * len,
                                 trip[i].t *= 2, trip[i].id = i;
  }
  if (!solve()) {
    printf("NO\n");
    return;
  }
  printf("YES\n");
  for (int i = (0); i < (n); ++i)
    printf("%d %d\n", ans[i].first, ans[i].second);
}
int main() {
  run();
  return 0;
}
