#include <bits/stdc++.h>
using namespace std;
struct L {
  int a, b, c;
  L() {}
  L(int a, int b, int c) : a(a), b(b), c(c) {}
} l[120005];
int r[30005], v[30005], w[120005];
vector<int> f[30005], ans;
vector<int>::iterator it;
int a, b, c, n, m;
queue<int> q;
int main() {
  scanf("%d", &n);
  memset(v, 0, sizeof v);
  memset(w, 0, sizeof w);
  for (int i = 1; i <= n; i++) {
    r[i] = 9;
  }
  for (int i = 0; i < 4 * n; i++) {
    scanf("%d %d %d", &a, &b, &c);
    l[i] = L(a, b, c);
    f[b].push_back(i);
    f[c].push_back(i);
    r[a]--;
  }
  for (int i = 1; i <= n; i++) {
    if (r[i] < 0) {
      puts("NO");
      return 0;
    }
    for (int j = 0; j < f[i].size() && r[i] > 0; j++) {
      int x = f[i][j];
      if (w[x]) continue;
      a = l[x].a;
      b = l[x].b;
      c = l[x].c;
      if ((b != c && (r[b] >= 0 + (a != b)) && (r[c] >= 0 + (a != c))) ||
          (b == c && r[b] >= 1 + (a != b))) {
        r[b]--;
        r[c]--;
        r[a]++;
        m++;
        ans.push_back(x);
        w[x] = 1;
        if (!v[a]) q.push(a), v[a] = 1;
      }
      if (m == 4 * n) break;
    }
  }
  while (q.size()) {
    int i = q.front();
    q.pop();
    v[i] = 0;
    for (int j = 0; j < f[i].size() && r[i] > 0; j++) {
      int x = f[i][j];
      if (w[x]) continue;
      a = l[x].a;
      b = l[x].b;
      c = l[x].c;
      if ((b != c && (r[b] >= 0 + (a != b)) && (r[c] >= 0 + (a != c))) ||
          (b == c && r[b] >= 1 + (a != b))) {
        r[b]--;
        r[c]--;
        r[a]++;
        m++;
        ans.push_back(x);
        w[x] = 1;
        if (!v[a]) q.push(a), v[a] = 1;
      }
      if (m == 4 * n) break;
    }
  }
  if (m != n * 4) {
    puts("NO");
    return 0;
  }
  puts("YES");
  for (int i = 0; i < ans.size(); i++) {
    printf("%d", ans[i] + 1);
    if (i == ans.size() - 1)
      puts("");
    else
      putchar(' ');
  }
}
