#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const int TRIPSMAX = 22;
const int NMAX = (1 << TRIPSMAX);
long long dp[NMAX];
int pred[NMAX];
int debVisa[NMAX];
const long long IMPOSSIBLE = (long long)1000 * 1000 * 1000 * 100;
struct Trip {
  long long deb, fin, visa, id;
};
Trip trips[TRIPSMAX];
int ordreVisa[TRIPSMAX];
bool compTrip(const Trip& a, const Trip& b) { return a.deb < b.deb; }
bool compVisa(const int& a, const int& b) {
  return trips[a].visa < trips[b].visa;
}
int n, p;
inline void propage(int situation, int iTrip, int debutVisa) {
  int nouvelleSituation = situation | (1 << iTrip);
  if (debutVisa + trips[iTrip].visa < trips[iTrip].deb &&
      dp[nouvelleSituation] > debutVisa + trips[iTrip].visa) {
    dp[nouvelleSituation] = debutVisa + trips[iTrip].visa;
    pred[nouvelleSituation] = iTrip;
    debVisa[nouvelleSituation] = debutVisa;
  }
}
inline int prochain(int situation, int cur) {
  for (int i = cur + 1; i < n; i++)
    if (situation & (1 << i)) return i;
  return -1;
}
pair<int, int> result[TRIPSMAX + 1];
int main() {
  fill(dp, dp + NMAX, IMPOSSIBLE);
  scanf("%d%d", &n, &p);
  for (int i = 0; i < n; i++) {
    long long s, len, t;
    scanf("%I64d%I64d%I64d", &s, &len, &t);
    trips[i].deb = s;
    trips[i].fin = s + len;
    trips[i].visa = t;
    trips[i].id = i + 1;
    ordreVisa[i] = i;
  }
  sort(trips, trips + n, compTrip);
  sort(ordreVisa, ordreVisa + n, compVisa);
  dp[0] = 1;
  for (int i = 0; i < (1 << n) - 1; i++) {
    int borne = dp[i];
    bool borneDepassee = false;
    int prochainDeSituation = prochain(i, -1);
    int iTrans = 0;
    for (int iTrip = 0; iTrip < n; iTrip++) {
      if (!borneDepassee && borne >= trips[iTrip].deb &&
          borne <= trips[iTrip].fin)
        borneDepassee = true;
      else if (!borneDepassee && borne < trips[iTrip].deb) {
        borneDepassee = true;
        for (int jTrans = 0;
             jTrans < n &&
             borne + trips[ordreVisa[jTrans]].visa <
                 (prochainDeSituation != -1 ? trips[prochainDeSituation].deb
                                            : IMPOSSIBLE);
             jTrans++)
          propage(i, ordreVisa[jTrans], borne);
      }
      if (i & (1 << iTrip))
        prochainDeSituation = prochain(i, prochainDeSituation);
      if (borneDepassee &&
          (iTrip == n - 1 || trips[iTrip].fin < trips[iTrip + 1].deb))
        for (; iTrans < n &&
               trips[iTrip].fin + trips[ordreVisa[iTrans]].visa <
                   (prochainDeSituation != -1 ? trips[prochainDeSituation].deb
                                              : IMPOSSIBLE);
             iTrans++)
          propage(i, ordreVisa[iTrans], trips[iTrip].fin);
    }
  }
  if (p == 1) {
    if (dp[(1 << n) - 1] == IMPOSSIBLE) {
      printf("NO");
      exit(0);
    }
    for (int situation = (1 << n) - 1; situation != 0;
         situation &= (~(1 << pred[situation]))) {
      result[trips[pred[situation]].id] = make_pair(1, debVisa[situation]);
    }
  } else {
    bool cherche = true;
    for (int i = 0; i < (1 << n) && cherche; i++) {
      int complementaire = ((1 << n) - 1) & (~i);
      if (dp[i] != IMPOSSIBLE && dp[complementaire] != IMPOSSIBLE) {
        cherche = false;
        for (int situation = i; situation != 0;
             situation &= (~(1 << pred[situation]))) {
          result[trips[pred[situation]].id] = make_pair(1, debVisa[situation]);
        }
        for (int situation = complementaire; situation != 0;
             situation &= (~(1 << pred[situation]))) {
          result[trips[pred[situation]].id] = make_pair(2, debVisa[situation]);
        }
      }
    }
    if (cherche) {
      printf("NO");
      exit(0);
    }
  }
  printf("YES\n");
  for (int i = 1; i <= n; i++)
    printf("%d %d\n", result[i].first, result[i].second);
}
