#include <bits/stdc++.h>
using namespace std;
const int MAXN = 30007;
int prv[4 * MAXN], nxt[4 * MAXN], a[4 * MAXN], b[4 * MAXN], c[4 * MAXN],
    process[MAXN], ans[4 * MAXN];
void remove(int i) {
  nxt[prv[i]] = nxt[i];
  prv[nxt[i]] = prv[i];
}
bool valid(int id) {
  if (a[id] != b[id] and a[id] != c[id] and b[id] != c[id]) {
    if (process[b[id]] <= 8 and process[c[id]] <= 8)
      return true;
    else
      return false;
  }
  if (a[id] != b[id] and b[id] == c[id]) {
    return process[b[id]] <= 7;
  }
  if (c[id] != b[id]) {
    if (a[id] == b[id])
      return process[c[id]] <= 8;
    else
      return process[b[id]] <= 8;
  }
  return process[a[id]] <= 8;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; i++) process[i] = 4;
  for (int i = 1; i <= 4 * n; i++) {
    scanf("%d%d%d", a + i, b + i, c + i);
    prv[i] = i == 1 ? 4 * n : i - 1;
    nxt[i] = i == 4 * n ? 1 : i + 1;
  }
  int cnt = 0;
  int now = 1;
  while (cnt < 4 * n) {
    if (valid(now)) {
      ans[cnt++] = now;
      process[a[now]]--;
      process[b[now]]++;
      process[c[now]]++;
      remove(now);
    }
    now = nxt[now];
  }
  printf("YES\n");
  for (int i = 0; i < 4 * n; i++)
    printf("%d%c", ans[i], i < 4 * n - 1 ? ' ' : '\n');
  return 0;
}
