#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int INF = 2147483647;
const long long LINF = 9223372036854775807;
const double EPS = 1e-10;
const int MAXN = 3e4 + 50;
inline void EnableFileIO(const string& fileName) {
  if (fileName.empty()) return;
  freopen((fileName + ".in").c_str(), "r", stdin);
  freopen((fileName + ".out").c_str(), "w", stdout);
  return;
}
int n;
int pos[MAXN], cnt[MAXN], b[MAXN][4], c[MAXN][4], id[MAXN][4];
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    pq;
vector<int> ans;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  EnableFileIO("");
  cin >> n;
  for (int i = 0; i < 4 * n; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--, v--, w--;
    b[u][pos[u]] = v;
    c[u][pos[u]] = w;
    id[u][pos[u]] = i;
    pos[u]++;
  }
  for (int i = 0; i < n; i++) cnt[i] = 8, pq.push(make_pair(8, i));
  memset(pos, 0, sizeof pos);
  while (!pq.empty()) {
    int u = pq.top().second;
    pq.pop();
    if (pos[u] == 4 || cnt[u] == 9) continue;
    int v = b[u][pos[u]], w = c[u][pos[u]];
    ans.push_back(id[u][pos[u]]), pos[u]++;
    pq.push(make_pair(++cnt[u], u));
    pq.push(make_pair(--cnt[v], v));
    pq.push(make_pair(--cnt[w], w));
  }
  cout << "YES" << endl;
  for (int i = 4 * n - 1; i >= 0; i--) cout << ans[i] + 1 << ' ';
  cout << endl;
  return 0;
}
