#include <bits/stdc++.h>
using namespace std;
int n;
int a[1 << 20], b[1 << 20], c[1 << 20];
int sz[1 << 20];
set<pair<int, int> > S;
set<pair<int, int> >::iterator it;
vector<int> ans;
vector<int> g[1 << 20];
int used[1 << 20];
set<int> todo;
set<int>::iterator it1;
void rev(int id) {
  used[id] = 1;
  S.erase(make_pair(sz[b[id]], b[id]));
  sz[b[id]]--;
  S.insert(make_pair(sz[b[id]], b[id]));
  S.erase(make_pair(sz[c[id]], c[id]));
  sz[c[id]]--;
  S.insert(make_pair(sz[c[id]], c[id]));
  S.erase(make_pair(sz[a[id]], a[id]));
  sz[a[id]]++;
  S.insert(make_pair(sz[a[id]], a[id]));
  todo.erase(id);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n;
  for (int i = 1; i <= n * 4; i++) {
    cin >> a[i] >> b[i] >> c[i];
    g[b[i]].push_back(i);
    g[c[i]].push_back(i);
    sz[b[i]]++;
    sz[c[i]]++;
    todo.insert(i);
  }
  for (int i = 1; i <= n; i++) S.insert(make_pair(sz[i], i));
  for (int iter = n * 4; iter; --iter) {
    it = S.end();
    --it;
    int qv = (*it).second;
    if (sz[qv] == 9) {
      for (int j = 0; j < g[qv].size(); j++) {
        int id = g[qv][j];
        if (used[id]) continue;
        ans.push_back(id);
        rev(id);
        break;
      }
    } else {
      it1 = todo.begin();
      int id = (*it1);
      ans.push_back(id);
      rev(id);
    }
  }
  cout << "YES" << endl;
  reverse(ans.begin(), ans.end());
  for (int i = 0; i < ans.size(); i++) {
    if (i) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}
