#include <bits/stdc++.h>
using namespace std;
template <typename T, typename U>
inline void chkmax(T& x, U y) {
  if (x < y) x = y;
}
template <typename T, typename U>
inline void chkmin(T& x, U y) {
  if (y < x) x = y;
}
const int MAXN = 12e4 + 12;
int cnt[MAXN], a[MAXN], b[MAXN], c[MAXN], d[MAXN], used[MAXN];
vector<int> V[MAXN];
set<pair<int, int> > S;
int get(int x, int y, int z) {
  cnt[x]--, cnt[y]++, cnt[z]++;
  int ret = max(cnt[x], max(cnt[y], cnt[z]));
  cnt[x]++, cnt[y]--, cnt[z]--;
  return ret;
}
vector<int> ans;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= 4 * n; i++) {
    scanf("%d%d%d", &a[i], &b[i], &c[i]);
    V[a[i]].push_back(i);
    V[b[i]].push_back(i);
    V[c[i]].push_back(i);
  }
  for (int i = 1; i <= n; i++) cnt[i] = 4;
  for (int i = 1; i <= 4 * n; i++)
    d[i] = get(a[i], b[i], c[i]), S.insert(pair<int, int>(d[i], i));
  for (int times = 0; times < 4 * n; times++) {
    set<pair<int, int> >::iterator it = S.begin();
    int i = it->second;
    S.erase(it);
    used[i] = 1;
    if (d[i] > 9) {
      puts("NO");
      return 0;
    }
    ans.push_back(i);
    cnt[a[i]]--, cnt[b[i]]++, cnt[c[i]]++;
    for (int j = 0; j < ((int)(V[a[i]].size())); j++) {
      int k = V[a[i]][j];
      if (used[k]) continue;
      int now = get(a[k], b[k], c[k]);
      if (d[k] == now) continue;
      S.erase(pair<int, int>(d[k], k));
      d[k] = now;
      S.insert(pair<int, int>(d[k], k));
    }
    for (int j = 0; j < ((int)(V[b[i]].size())); j++) {
      int k = V[b[i]][j];
      if (used[k]) continue;
      int now = get(a[k], b[k], c[k]);
      if (d[k] == now) continue;
      S.erase(pair<int, int>(d[k], k));
      d[k] = now;
      S.insert(pair<int, int>(d[k], k));
    }
    for (int j = 0; j < ((int)(V[c[i]].size())); j++) {
      int k = V[c[i]][j];
      if (used[k]) continue;
      int now = get(a[k], b[k], c[k]);
      if (d[k] == now) continue;
      S.erase(pair<int, int>(d[k], k));
      d[k] = now;
      S.insert(pair<int, int>(d[k], k));
    }
  }
  puts("YES");
  for (int i = 0; i < 4 * n; i++) printf("%d ", ans[i]);
  return 0;
}
