#include <bits/stdc++.h>
using namespace std;
const int N = 100100;
int k[33000];
struct cp {
  int a, b, c, num;
};
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  cout << "YES\n";
  for (int i = 1; i <= n; i++) {
    k[i] = 4;
  }
  vector<cp> v(4 * n);
  for (int i = 0; i < 4 * n; i++) {
    cin >> v[i].a >> v[i].b >> v[i].c;
    v[i].num = i + 1;
  }
  int it = 0;
  while (v.size() != 0) {
    if (it == v.size()) it = 0;
    k[v[it].a]--;
    k[v[it].b]++;
    k[v[it].c]++;
    if (k[v[it].a] >= 0 && k[v[it].b] <= 9 && k[v[it].c] <= 9) {
      cout << v[it].num << " ";
      v[it] = v.back();
      v.pop_back();
      continue;
    }
    k[v[it].a]++;
    k[v[it].b]--;
    k[v[it].c]--;
    it++;
  }
  return 0;
}
