#include <bits/stdc++.h>
using namespace std;
struct Node {
  int a, b, c, idx;
};
const int maxn = 30001;
int n;
int have[maxn];
queue<Node> q;
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) have[i] = 4;
  for (int i = 1; i <= 4 * n; i++) {
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);
    q.push(Node{a, b, c, i});
  }
  puts("YES");
  while (!q.empty()) {
    Node node = q.front();
    q.pop();
    have[node.a]--, have[node.b]++, have[node.c]++;
    if (have[node.b] <= 9 && have[node.c] <= 9) {
      printf("%d ", node.idx);
      continue;
    }
    have[node.a]++, have[node.b]--, have[node.c]--;
    q.push(node);
  }
  puts("");
}
