#include <bits/stdc++.h>
using namespace std;
bool debug = 1;
int n, m, k;
int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
long long ln, lk, lm;
int cnt[30125 * 4];
int l[30125 * 4], r[30125 * 4];
int a[30125 * 4], b[30125 * 4], c[30125 * 4];
vector<int> ans;
bool add(int x) {
  cnt[a[x]]--;
  cnt[b[x]]++;
  cnt[c[x]]++;
  if (cnt[b[x]] <= 5 && cnt[c[x]] <= 5) {
    ans.push_back(x);
    return 1;
  }
  cnt[a[x]]++;
  cnt[b[x]]--;
  cnt[c[x]]--;
  return 0;
}
void fmain() {
  scanf("%d", &n);
  for (int i = 1; i <= n * 4; i++) {
    scanf("%d%d%d", a + i, b + i, c + i);
    l[i] = i - 1;
    r[i] = i + 1;
  }
  l[1] = n * 4;
  r[4 * n] = 1;
  for (int j = 1; ans.size() < n * 4; j = r[j]) {
    while (!add(j)) {
      j = r[j];
    }
    r[l[j]] = r[j];
    l[r[j]] = l[j];
  }
  puts("YES");
  for (int c : ans) printf("%d ", c);
}
int main() {
  fmain();
  return 0;
}
