#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:102400000,102400000")
using namespace std;
vector<int> g[30010];
int b[30010 << 2], c[30010 << 2], cnt[30010], n, vis[30010][4], pr[30010],
    ne[30010], num[30010];
int q[30010 << 2], top;
void cal(int u) {
  pr[ne[u]] = pr[u];
  ne[pr[u]] = ne[u];
}
void cal1(int u) {
  ne[pr[u]] = u;
  pr[ne[u]] = u;
}
bool dfs(int u, int m = 0) {
  if (m == n * 4) {
    return 1;
  }
  for (int i = 0; i < g[u].size(); i++) {
    if (vis[u][i]) continue;
    int j = g[u][i];
    int first = b[j], second = c[j];
    if (first == second && first == u) {
      if (cnt[u] + 1 <= 9) {
        cnt[u]++, q[top++] = j;
        vis[u][i] = 1;
        num[u]++;
        if (num[u] == 4) cal(u);
        if (dfs(u, m + 1)) return 1;
        if (num[u] == 4) cal1(u);
        cnt[u]--, vis[u][i] = 0;
        top--;
        num[u]--;
      }
    } else if (first == second) {
      if (cnt[first] + 2 <= 9) {
        cnt[u]--, vis[u][i] = 1;
        cnt[first] += 2;
        q[top++] = j;
        num[u]++;
        if (num[u] == 4) cal(u);
        if (dfs(first, m + 1)) return 1;
        if (num[u] == 4) cal1(u);
        cnt[u]++, vis[u][i] = 0;
        cnt[first] -= 2;
        top--;
        num[u]--;
      }
    } else if (first == u || second == u) {
      if (second == u) swap(first, second);
      if (cnt[second] + 1 <= 9) {
        cnt[second]++;
        vis[u][i] = 1;
        q[top++] = j;
        num[u]++;
        if (num[u] == 4) cal(u);
        if (dfs(second, m + 1)) return 1;
        if (num[u] == 4) cal1(u);
        cnt[second]--, vis[u][i] = 0;
        top--;
        num[u]--;
      }
    } else {
      if (cnt[first] + 1 <= 9 && cnt[second] + 1 <= 9) {
        cnt[u]--, vis[u][i] = 1;
        cnt[first]++, cnt[second]++;
        q[top++] = j;
        num[u]++;
        if (num[u] == 4) cal(u);
        if (dfs(u, m + 1)) return 1;
        if (num[u] == 4) cal1(u);
        cnt[u]++, vis[u][i] = 0;
        cnt[first]--, cnt[second]--;
        top--;
        num[u]--;
      }
    }
  }
  if (dfs(ne[u], m)) return 1;
  return 0;
}
int main() {
  int Ta, i, j, k, ca = 0, m;
  scanf("%d", &n);
  for (i = 0; i < n * 4; i++) {
    int a;
    scanf("%d%d%d", &a, &b[i], &c[i]);
    a--, b[i]--, c[i]--;
    g[a].push_back(i);
  }
  for (i = 0; i < n; i++) cnt[i] = 4, ne[i] = i + 1, pr[i] = i - 1;
  pr[0] = n - 1, ne[n - 1] = 0;
  if (dfs(0)) {
    puts("YES");
    for (i = 0; i < top - 1; i++) printf("%d ", q[i] + 1);
    printf("%d\n", q[i] + 1);
  } else
    puts("NO");
  return 0;
}
