#include <bits/stdc++.h>
using namespace std;
priority_queue<pair<int, int> > q;
vector<int> ans;
int n;
int b[30005][10];
int c[30005][10];
int id[30005][10];
int pos[30005];
int cnt[30005];
int main() {
  cin >> n;
  for (int i = 1; i <= n * 4; i++) {
    int p, q, r;
    cin >> p >> q >> r;
    pos[p]++;
    b[p][pos[p]] = q;
    c[p][pos[p]] = r;
    id[p][pos[p]] = i;
  }
  for (int i = 1; i <= n; i++) {
    cnt[i] = 8;
  }
  for (int i = 1; i <= n; i++) {
    q.push(make_pair(-8, i));
  }
  for (int i = 1; i <= n; i++) {
    pos[i] = 1;
  }
  while (!q.empty()) {
    int x = q.top().second;
    q.pop();
    if (pos[x] == 5 || cnt[x] == 9) {
      continue;
    }
    int t1 = b[x][pos[x]];
    int t2 = c[x][pos[x]];
    cnt[x]++;
    cnt[t1]--;
    cnt[t2]--;
    ans.push_back(id[x][pos[x]]);
    pos[x]++;
    q.push(make_pair(-cnt[x], x));
    q.push(make_pair(-cnt[t1], t1));
    q.push(make_pair(-cnt[t2], t2));
  }
  cout << "YES" << endl;
  for (int i = n * 4 - 1; i >= 0; i--) {
    cout << ans[i] << " ";
  }
  return 0;
}
