#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int MAXN = 22;
const int INF = 2000 << 20;
int n;
int s[MAXN], l[MAXN], t[MAXN];
int dp[1 << MAXN];
pair<pair<int, int>, int> ints[MAXN + 1];
int which[1 << MAXN], when[1 << MAXN];
int id[MAXN], date[MAXN];
int solve(int mask) {
  int i, x, j, prv;
  if (mask == 0) return 1;
  if (dp[mask] != -1) return dp[mask];
  dp[mask] = INF;
  for (i = 0; i < n; ++i)
    if (mask & 1 << i) {
      x = solve(mask ^ 1 << i);
      if (x == INF) continue;
      j = upper_bound(ints, ints + n, make_pair(make_pair(x, INF), 0)) - ints -
          1;
      prv = INF;
      if (j == -1 || ints[j].first.second < x) {
        ++j;
        prv = x;
      }
      for (; j < n && (ints[j].first.first - prv <= t[i]); ++j)
        if (mask & 1 << ints[j].second || prv == INF) {
          if (ints[j + 1].first.first == ints[j].first.second)
            prv = INF;
          else
            prv = ints[j].first.second;
        }
      x = prv + t[i];
      if (x <= s[i] && x < dp[mask]) {
        dp[mask] = x;
        which[mask] = i;
        when[mask] = prv;
      }
    }
  return dp[mask];
}
void solve() {
  dp[0] = 1;
  int mask, i, j, x, prv;
  for (mask = 1; mask < (1 << n); ++mask) {
    dp[mask] = INF;
    for (i = 0; i < n; ++i)
      if (mask & 1 << i) {
        x = dp[mask ^ 1 << i];
        if (x == INF) continue;
        j = upper_bound(ints, ints + n, make_pair(make_pair(x, INF), 0)) -
            ints - 1;
        prv = INF;
        if (j == -1 || ints[j].first.second < x) {
          ++j;
          prv = x;
        }
        for (; j < n && (ints[j].first.first - prv <= t[i]); ++j)
          if (mask & 1 << ints[j].second || prv == INF) {
            if (ints[j + 1].first.first == ints[j].first.second)
              prv = INF;
            else
              prv = ints[j].first.second;
          }
        x = prv + t[i];
        if (x <= s[i] && x < dp[mask]) {
          dp[mask] = x;
          which[mask] = i;
          when[mask] = prv;
        }
      }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int p, i, mask1, mask2;
  cin >> n >> p;
  for (i = 0; i < n; ++i) {
    cin >> s[i] >> l[i] >> t[i];
    ints[i] = {{s[i], s[i] + l[i]}, i};
  }
  ints[n] = {{INF, INF}, n};
  sort(ints, ints + n);
  solve();
  if (p == 1) {
    if (solve((1 << n) - 1) != INF) {
      cout << "YES\n";
      for (int mask = (1 << n) - 1; mask; mask ^= 1 << which[mask]) {
        id[which[mask]] = 1;
        date[which[mask]] = when[mask];
      }
      for (i = 0; i < n; ++i) cout << id[i] << ' ' << date[i] << '\n';
    } else {
      cout << "NO\n";
    }
  } else {
    for (mask1 = 0; mask1 < (1 << n); ++mask1) {
      mask2 = mask1 ^ ((1 << n) - 1);
      if (solve(mask1) != INF && solve(mask2) != INF) {
        cout << "YES\n";
        for (; mask1; mask1 ^= 1 << which[mask1]) {
          id[which[mask1]] = 1;
          date[which[mask1]] = when[mask1];
        }
        for (; mask2; mask2 ^= 1 << which[mask2]) {
          id[which[mask2]] = 2;
          date[which[mask2]] = when[mask2];
        }
        for (i = 0; i < n; ++i) cout << id[i] << ' ' << date[i] << '\n';
        return 0;
      }
    }
    cout << "NO\n";
  }
}
