#include <bits/stdc++.h>
using namespace std;
const int INF_of_int = 2e9 + 10;
const int N = 23;
int n, p, m, limit;
int dp[1 << N];
pair<int, int> times[N], trans[1 << N], line[N], ans[N];
struct Node {
  int s, len, t, id;
} a[N];
bool operator<(const Node a, const Node b) { return a.s < b.s; }
bool solve1() {
  dp[0] = 0;
  for (int s = 1; s < limit; s++) {
    dp[s] = INF_of_int;
    for (int cur = 0; cur < n; cur++)
      if (s & (1 << cur)) {
        int pre = s ^ (1 << cur);
        if (dp[pre] == INF_of_int) continue;
        for (int i = 0; i < m; i++) {
          int bg = max(times[i].first, dp[pre]), ed = bg + a[cur].t;
          if (ed >= a[cur].s + a[cur].len - 1 || ed >= dp[s]) break;
          if (times[i].second < ed) continue;
          dp[s] = ed;
          trans[s] = pair<int, int>(cur, bg);
          break;
        }
      }
  }
  if (dp[limit - 1] == INF_of_int) {
    return 0;
  } else {
    for (int cur = limit - 1; cur; cur ^= 1 << trans[cur].first)
      ans[a[trans[cur].first].id] = pair<int, int>(1, trans[cur].second);
    return 1;
  }
}
bool solve2() {
  dp[0] = 0;
  for (int s = 1; s < limit; s++) {
    dp[s] = INF_of_int;
    int tmp = 0, last = 1;
    for (int cur = 0; cur < n; cur++)
      if (s & (1 << cur)) {
        if (last <= a[cur].s - 1)
          line[tmp++] = pair<int, int>(last, a[cur].s - 1);
        last = a[cur].s + a[cur].len;
        int pre = s ^ (1 << cur), stp = 0;
        if (dp[pre] == INF_of_int) continue;
        for (int i = 0; i < m; i++)
          if (dp[pre] < times[i].second) {
            int bg = max(times[i].first, dp[pre]), ed = bg + a[cur].t;
            if (dp[s] <= ed) break;
            for (; stp <= tmp && line[stp].second <= bg; ++stp)
              ;
            if (stp > tmp || ed >= a[cur].s) break;
            if (line[stp].first > bg || line[stp].second < ed) continue;
            dp[s] = ed;
            trans[s] = pair<int, int>(cur, bg);
            break;
          }
      }
  }
  for (int s1 = 0; s1 < limit; s1++) {
    int s2 = (limit - 1) ^ s1;
    if (s1 <= s2 && dp[s1] < INF_of_int && dp[s2] < INF_of_int) {
      for (int cur = s1; cur; cur ^= 1 << trans[cur].first)
        ans[a[trans[cur].first].id] = pair<int, int>(1, trans[cur].second);
      for (int cur = s2; cur; cur ^= 1 << trans[cur].first)
        ans[a[trans[cur].first].id] = pair<int, int>(2, trans[cur].second);
      return 1;
    }
  }
  return 0;
}
int main() {
  scanf("%d %d", &n, &p);
  for (int i = 0; i < n; i++) {
    scanf("%d %d %d", &a[i].s, &a[i].len, &a[i].t);
    a[i].id = i;
  }
  sort(a, a + n);
  limit = 1 << n;
  for (int i = 0, last = 1; i < n; last = a[i].s + a[i].len, i++)
    if (last <= a[i].s - 1) times[m++] = pair<int, int>(last, a[i].s - 1);
  if (p == 1 ? solve1() : solve2()) {
    puts("YES");
    for (int i = 0; i < n; i++) printf("%d %d\n", ans[i].first, ans[i].second);
  } else {
    puts("NO");
  }
  return 0;
}
