#include <bits/stdc++.h>
using namespace std;
int cas = 1, T;
int n, a[30100 << 2], b[30100 << 2], c[30100 << 2], v[30100], s[30100],
    vis[30100 << 2];
int main() {
  while (scanf("%d", &n) == 1) {
    memset(v, 0, sizeof(v));
    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n << 2; i++) scanf("%d%d%d", a + i, b + i, c + i);
    int all = n << 2;
    for (int i = 1; i <= n; i++) s[i] = 4;
    puts("YES");
    while (all) {
      for (int i = 1; i <= n << 2; i++) {
        if (!vis[i]) {
          if (b[i] == c[i] && s[b[i]] + v[b[i]] < 8) {
            vis[i] = 1;
            all--;
            s[a[i]]--;
            v[b[i]] += 2;
            printf("%d ", i);
          } else if (b[i] != c[i] && s[b[i]] + v[b[i]] < 9 &&
                     s[c[i]] + v[c[i]] < 9) {
            vis[i] = 1;
            all--;
            s[a[i]]--;
            v[b[i]]++;
            v[c[i]]++;
            printf("%d ", i);
          }
        }
      }
    }
    printf("\n");
  }
  return 0;
}
