#include <bits/stdc++.h>
using namespace std;
int n, a[200200], b[200200], c[200200], used[200200], cnt[30300];
vector<int> r[30300], ans;
set<int> H;
bool check(int r_id) {
  if (b[r_id] == c[r_id]) {
    if (a[r_id] == b[r_id]) {
      return cnt[c[r_id]] < 9;
    } else {
      return cnt[c[r_id]] < 8;
    }
  } else {
    if (a[r_id] != b[r_id]) {
      if (cnt[b[r_id]] == 9) return false;
    }
    if (a[r_id] != c[r_id]) {
      if (cnt[c[r_id]] == 9) return false;
    }
    return true;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < 4 * n; i++) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    r[a[i]].push_back(i);
    r[b[i]].push_back(i);
    r[c[i]].push_back(i);
    H.insert(i);
  }
  for (int i = 0; i < n; i++) {
    cnt[i + 1] = 4;
  }
  puts("YES");
  while (!H.empty()) {
    int me = *H.begin();
    used[me] = 1;
    H.erase(me);
    int now[3] = {a[me], b[me], c[me]};
    cnt[a[me]]--;
    cnt[b[me]]++;
    cnt[c[me]]++;
    ans.push_back(me + 1);
    for (int k = 0; k < 3; k++) {
      int id = now[k];
      for (int i = 0; i < r[id].size(); i++) {
        int r_id = r[id][i];
        if (!used[r_id]) {
          if (check(r_id)) {
            H.insert(r_id);
          } else {
            if (H.count(r_id)) H.erase(r_id);
          }
        }
      }
    }
  }
  for (__typeof(ans.begin()) it(ans.begin()); it != ans.end(); it++) {
    printf("%d ", *it);
  }
  puts("");
  return 0;
}
