#include <bits/stdc++.h>
using namespace std;
int n;
int val[250000], res[250000], vis[250000];
;
pair<pair<int, int>, pair<int, int> > a[250000];
inline bool check(int x) {
  val[a[x].first.first]--;
  val[a[x].second.first]++;
  val[a[x].second.second]++;
  if (val[a[x].second.first] <= 9 && val[a[x].second.second] <= 9) return true;
  val[a[x].first.first]++;
  val[a[x].second.first]--;
  val[a[x].second.second]--;
  return false;
}
int main() {
  srand(time(0));
  scanf("%d", &n);
  n *= 4;
  for (int i = 1; i <= n; i++) {
    val[i] = 4;
    a[i].first.second = i;
    scanf("%d %d %d", &a[i].first, &a[i].second.first, &a[i].second.second);
  }
  random_shuffle(a + 1, a + n + 1);
  int cnt = 0;
  while (cnt != n) {
    int tp = 0;
    for (int i = 1; i <= n; i++) {
      if (vis[i] == 0 && check(i)) {
        tp++;
        cnt++;
        vis[i] = 1;
        res[cnt] = a[i].first.second;
        ;
      }
    }
    if (tp == 0) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  for (int i = 1; i <= n; i++) printf("%d ", res[i]);
  printf("\n");
  return 0;
}
