#include <bits/stdc++.h>
using namespace std;
int n;
int f[30010];
int A[30010 * 4], B[30010 * 4], C[30010 * 4];
struct node {
  int id, v;
  bool operator>(node const &ano) const { return v > ano.v; }
};
void Plus(int id, int v) {
  f[A[id]] -= v;
  f[B[id]] += v;
  f[C[id]] += v;
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) f[i] = 4;
  priority_queue<node, vector<node>, greater<node> > q;
  int cnt = 0;
  for (int i = 1; i <= n * 4; ++i)
    scanf("%d%d%d", &A[i], &B[i], &C[i]), q.push((node){i, ++cnt});
  printf("YES\n");
  for (; !q.empty();) {
    int id = q.top().id;
    q.pop();
    Plus(id, 1);
    if (f[B[id]] > 9 || f[C[id]] > 9) {
      Plus(id, -1);
      q.push((node){id, ++cnt});
      continue;
    }
    printf("%d ", id);
  }
  return 0;
}
