#include <bits/stdc++.h>
using namespace std;
const int MN = 30010;
int N;
struct Info {
  int a, b, c;
};
Info info[MN << 2];
set<int> st;
vector<int> adj1[MN], adj2[MN];
int deg[MN], chk[MN << 2], used[MN << 2];
void relax(int u, int t) {
  if (t) {
    if (deg[u] == 7) {
      for (int i = 0; i < adj2[u].size(); i++) {
        int v = adj2[u][i];
        if (used[v]) continue;
        chk[v]--;
        if (!chk[v]) st.insert(v);
      }
    }
    if (deg[u] == 8) {
      for (int i = 0; i < adj1[u].size(); i++) {
        int v = adj1[u][i];
        if (used[v]) continue;
        chk[v]--;
        if (!chk[v]) st.insert(v);
      }
    }
  } else {
    if (deg[u] == 8) {
      for (int i = 0; i < adj2[u].size(); i++) {
        int v = adj2[u][i];
        if (!chk[v]) st.erase(v);
        chk[v]++;
      }
    }
    if (deg[u] == 9) {
      for (int i = 0; i < adj1[u].size(); i++) {
        int v = adj1[u][i];
        if (!chk[v]) st.erase(v);
        chk[v]++;
      }
    }
  }
}
int main() {
  scanf("%d", &N);
  for (int i = 0; i < 4 * N; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    a--;
    b--;
    c--;
    info[i] = {a, b, c};
    deg[a]--;
    deg[b]++;
    deg[c]++;
    if (deg[b] == 1) adj1[b].push_back(i);
    if (b != c && deg[c] == 1) adj1[c].push_back(i);
    if (deg[b] == 2) adj2[b].push_back(i);
    deg[a]++;
    deg[b]--;
    deg[c]--;
  }
  printf("YES\n");
  for (int i = 0; i < 4 * N; i++) st.insert(i);
  for (int i = 0; i < N; i++) deg[i] = 4;
  while (!st.empty()) {
    int u = *st.begin();
    st.erase(u);
    if (used[u]) continue;
    printf("%d ", u + 1);
    used[u] = 1;
    int a = info[u].a;
    int b = info[u].b;
    int c = info[u].c;
    deg[a]--;
    relax(a, 1);
    deg[b]++;
    relax(b, 0);
    deg[c]++;
    relax(c, 0);
  }
}
