#include <bits/stdc++.h>
using namespace std;
const int MAXN = 120000;
const int MOD = 1000000007;
const int INF = ((1 << 31) - 1);
int n, naso;
int cnt[MAXN + 5];
int a[MAXN + 5], b[MAXN + 5], c[MAXN + 5];
int sol[MAXN + 5];
bool bio[MAXN + 5];
bool ok(int cx) {
  if (bio[cx]) return 0;
  if (b[cx] == c[cx] && cnt[b[cx]] >= 8) return 0;
  if (cnt[b[cx]] == 9 || cnt[c[cx]] == 9) return 0;
  return 1;
}
int main() {
  scanf("%d", &n);
  for (int i = (0), _for = (n * 4); i < _for; ++i) {
    scanf("%d%d%d", a + i, b + i, c + i);
    cnt[a[i]]++;
  }
  bool flag = 1;
  while (flag) {
    flag = 0;
    for (int i = (0), _for = (n * 4); i < _for; ++i) {
      if (ok(i)) {
        sol[naso++] = i;
        bio[i] = 1;
        cnt[a[i]]--;
        cnt[b[i]]++;
        cnt[c[i]]++;
        flag = 1;
      }
    }
  }
  puts("YES");
  for (int i = (0), _for = (naso); i < _for; ++i) printf("%d ", sol[i] + 1);
  return 0;
}
