#include <bits/stdc++.h>
using namespace std;
struct node {
  int b, c, i;
  node(int x = 0, int y = 0, int z = 0) {
    b = x;
    c = y;
    i = z;
  }
};
vector<node> a[30010];
int n;
char vis[30010];
int main() {
  while (scanf("%d", &n) == 1) {
    memset(vis, 4, sizeof(vis));
    int i, tmp, tmp1, tmp2, j, num;
    for (i = 0; i <= n; i++) a[i].clear();
    n *= 4;
    num = n;
    for (i = 1; i <= n; i++) {
      scanf("%d%d%d", &tmp, &tmp1, &tmp2);
      a[tmp].push_back(node(tmp1, tmp2, i));
    }
    n /= 4;
    puts("YES");
    int work = 1;
    while (work) {
      work = 0;
      for (j = 1; j <= n; j++) {
        if (!a[j].empty())
          for (vector<node>::iterator k = a[j].begin(); k != a[j].end(); k++) {
            --vis[j];
            ++vis[k->b];
            ++vis[k->c];
            work = 1;
            if (vis[k->b] < 10 && vis[k->c] < 10) {
              printf("%d", k->i);
              num--;
              if (num) printf(" ");
              a[j].erase(k);
              break;
            } else {
              ++vis[j];
              --vis[k->b];
              --vis[k->c];
            }
          }
      }
    }
    puts("");
  }
  return 0;
}
