#include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > s;
set<pair<int, int> >::iterator it;
int cnt[150010];
int a[150010], b[150010], c[150010];
int ans[150010];
int adj[150010][5], vst[150010], deg[150010];
queue<int> q;
int hop[150010];
int main() {
  int N, ct, u, r;
  scanf("%d", &N);
  memset(vst, 0, sizeof(vst));
  memset(hop, 0, sizeof(hop));
  memset(deg, 0, sizeof(deg));
  for (int i = (1); i < (N + 1); i++) cnt[i] = 4;
  ct = 0;
  for (int i = (1); i < (4 * N + 1); i++) {
    scanf("%d%d%d", a + i, b + i, c + i);
    adj[a[i]][deg[a[i]]++] = i;
  }
  while (1) {
    if (ct == 4 * N) break;
    q = queue<int>();
    bool ok = false;
    for (int i = (1); i < (4 * N + 1); i++) {
      if (hop[i]) continue;
      if (cnt[b[i]] == 9) continue;
      if (cnt[c[i]] == 9) continue;
      if (cnt[b[i]] == 8 && b[i] == c[i] && b[i] != a[i]) continue;
      ans[ct++] = i;
      cnt[a[i]]--;
      cnt[b[i]]++;
      cnt[c[i]]++;
      hop[i] = 1;
      if (!vst[b[i]]) {
        q.push(b[i]);
        vst[b[i]] = 1;
      }
      if (!vst[c[i]]) {
        q.push(c[i]);
        vst[c[i]] = 1;
      }
      ok = true;
    }
    if (!ok) break;
    while (!q.empty()) {
      u = q.front();
      q.pop();
      vst[u] = 0;
      for (int i = (0); i < (4); i++) {
        r = adj[u][i];
        if (hop[r]) continue;
        if (cnt[b[r]] == 9) continue;
        if (cnt[c[r]] == 9) continue;
        if (cnt[b[r]] == 8 && b[r] == c[r] && b[r] != a[r]) continue;
        cnt[a[r]]--;
        cnt[b[r]]++;
        cnt[c[r]]++;
        hop[r] = 1;
        ans[ct++] = r;
        if (!vst[b[r]]) {
          vst[b[r]] = 1;
          q.push(b[r]);
        }
        if (!vst[c[r]]) {
          vst[c[r]] = 1;
          q.push(c[r]);
        }
      }
    }
  }
  if (ct < 4 * N)
    puts("NO");
  else {
    puts("YES");
    for (int i = (0); i < (ct); i++)
      if (i == ct - 1)
        printf("%d\n", ans[i]);
      else
        printf("%d ", ans[i]);
  }
  return 0;
}
