#include <bits/stdc++.h>
using namespace std;
int cnt;
int n, a[150000], b[150000], c[150000], sz[150000], v[150000];
int sol[150000];
queue<int> F, D[150000];
int main() {
  scanf("%d", &n);
  for (int i = (0); i < (n * 4); i++) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    --a[i], --b[i], --c[i];
    F.push(i);
  }
  for (int i = (0); i < (n); i++) sz[i] = 4;
  while (cnt < n * 4) {
    if (F.size() == 0) {
    }
    int x = F.front();
    F.pop();
    --sz[a[x]];
    if (b[x] == c[x]) {
      if (sz[b[x]] < 8) {
        sz[b[x]] += 2;
        sol[cnt++] = x;
        v[x] = 1;
        if (a[x] != b[x]) {
          while (D[a[x]].size() > 0) {
            int y = D[a[x]].front();
            D[a[x]].pop();
            if (!v[y]) F.push(y);
          }
        }
      } else
        D[b[x]].push(x), ++sz[a[x]];
      continue;
    }
    if (sz[b[x]] < 9 && sz[c[x]] < 9) {
      sz[b[x]]++;
      sz[c[x]]++;
      v[x] = 1;
      sol[cnt++] = x;
      if (a[x] == b[x] || a[x] == c[x]) continue;
      while (D[a[x]].size() > 0) {
        int y = D[a[x]].front();
        D[a[x]].pop();
        if (!v[y]) F.push(y);
      }
    } else if (sz[b[x]] < 9 && sz[c[x]] == 9)
      D[c[x]].push(x), ++sz[a[x]];
    else
      D[b[x]].push(x), ++sz[a[x]];
  }
  puts("YES");
  for (int i = (0); i < (n * 4); i++) printf("%d ", sol[i] + 1);
  return 0;
}
