#include <bits/stdc++.h>
using namespace std;
struct rule {
  int a, b, c, ind;
};
int cuantos[1000000];
int main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<rule> v(4 * n);
  for (int i = 0; i < 4 * n; i++) {
    cin >> v[i].a >> v[i].b >> v[i].c;
    v[i].ind = i + 1;
  }
  random_shuffle(v.begin(), v.end());
  queue<rule> q;
  for (int i = 0; i < int(v.size()); i++) q.push(v[i]);
  for (int i = 1; i <= n; i++) cuantos[i] = 4;
  vector<int> sol;
  while (not q.empty()) {
    rule r = q.front();
    q.pop();
    if (r.a == r.c) swap(r.b, r.c);
    if (cuantos[r.a] >= 0 and
        ((r.a != r.b and r.b != r.c and cuantos[r.b] < 9 and
          cuantos[r.c] < 9) or
         (r.a != r.b and r.b == r.c and cuantos[r.b] < 8) or
         (r.a == r.b and r.b != r.c and cuantos[r.c] < 9) or
         (r.a == r.b and r.b == r.c and cuantos[r.b] < 9))) {
      sol.push_back(r.ind);
      cuantos[r.a]--;
      cuantos[r.b]++;
      cuantos[r.c]++;
    } else {
      q.push(r);
    }
  }
  cout << "YES" << endl;
  for (int i = 0; i < int(sol.size()); i++) {
    if (i > 0) cout << " ";
    cout << sol[i];
  }
  cout << endl;
}
