#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int SIZE = 1e6 + 10;
int a[SIZE], b[SIZE], c[SIZE], cnt[SIZE];
bool used[SIZE];
vector<int> r[SIZE];
set<int> H;
void print_array(vector<int>& arr) {
  for (int i = 0; i < (((int)(arr).size())); ++i) {
    if (i) printf(" ");
    printf("%d", arr[i]);
  }
  puts("");
}
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() {
  int(n);
  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");
  vector<int> an;
  while (((int)(H).size())) {
    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]]++;
    an.push_back(me + 1);
    for (int k = 0; k < (3); ++k) {
      int id = now[k];
      for (int i = 0; i < (((int)(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);
          }
        }
      }
    }
  }
  print_array(an);
  assert(((int)(an).size()) == n * 4);
  return 0;
}
