#include <bits/stdc++.h>
using namespace std;
struct road {
  int x, y;
  int next;
} r[120005 * 4];
int N;
int d[120005], ans[120005], sum;
int st[120005], w;
set<pair<int, int> > s;
set<pair<int, int> >::iterator it;
void add(int x, int y, int z) {
  r[++w].x = y, r[w].y = z;
  r[w].next = st[x], st[x] = w;
}
int main() {
  int i, j;
  int x, y, z, tmp;
  scanf("%d", &N);
  for (i = 1; i <= N; i++) d[i] = 8, s.insert(make_pair(8, i));
  for (i = 1; i <= 4 * N; i++) {
    scanf("%d %d %d", &x, &y, &z);
    add(x, y, z);
  }
  while (!s.empty()) {
    x = (*s.begin()).second;
    if (d[x] == 9) break;
    tmp = st[x];
    s.erase(make_pair(d[x], x));
    if (!tmp) continue;
    ans[++sum] = st[x];
    st[x] = r[tmp].next;
    s.insert(make_pair(++d[x], x));
    y = r[tmp].x, z = r[tmp].y;
    if (y != z) {
      s.erase(make_pair(d[y], y)), s.erase(make_pair(d[z], z));
      s.insert(make_pair(--d[y], y)), s.insert(make_pair(--d[z], z));
    } else
      s.erase(make_pair(d[y], y)), s.insert(make_pair(--(--d[y]), y));
  }
  if (sum != 4 * N)
    printf("NO\n");
  else {
    printf("YES\n");
    for (i = 4 * N; i >= 1; i--) printf("%d ", ans[i]);
  }
  return 0;
}
