#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:1024000000,1024000000")
const long double pi = acosl(-1.);
int T;
const long long mod = 258280327;
long long gcd(long long x, long long y) {
  if (!y) return x;
  return gcd(y, x % y);
}
long long quickfind(long long x, long long y) {
  long long result = 1;
  while (y) {
    if (y & 1) result = result * x % mod;
    y >>= 1;
    x = x * x % mod;
  }
  return result;
}
using namespace std;
int dfn[33333];
int cnt[33333];
struct master {
  int x, y, z;
  master(int x = 0, int y = 0, int z = 0) : x(x), y(y), z(z) {}
};
int n;
int size[33333];
vector<master> cd[33333];
vector<int> ans;
int q[11111111] = {0};
int h = 5000000, t = 5000000 - 1;
void solve() {
  for (int i = 1; i <= n; i++) q[++t] = i, size[i] = 4;
  while (h <= t) {
    int x = q[h++];
    if ((int)cd[x].size() == 0) continue;
    int y = cd[x][(int)cd[x].size() - 1].x;
    int z = cd[x][(int)cd[x].size() - 1].y;
    size[x]--, size[y]++, size[z]++;
    if (size[y] > 9 || size[z] > 9) {
      size[x]++;
      size[y]--;
      size[z]--;
      q[++t] = x;
      continue;
    }
    ans.push_back(cd[x][(int)cd[x].size() - 1].z);
    cd[x].pop_back();
    q[++t] = x;
  }
}
int main() {
  srand(time(NULL));
  scanf("%d", &n);
  for (int i = 1; i <= n << 2; i++) {
    int a, b, c;
    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    cd[a].push_back(master(b, c, i));
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= 16; j++) {
      int x = rand() % 4;
      int y = rand() % 4;
      swap(cd[i][x], cd[i][y]);
    }
  }
  solve();
  if ((int)ans.size() == n * 4) {
    printf("YES\n");
    printf("%d", ans[0]);
    for (int i = 1; i <= (int)ans.size() - 1; i++) printf(" %d", ans[i]);
    puts("");
  } else
    printf("NO\n");
  return 0;
}
