#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<pair<int, pair<int, int> > > a;
  int n, ans[100010];
  set<int> visited;
  vector<int> final;
  int i, x, y, z;
  cin >> n;
  a.push_back(make_pair(0, make_pair(0, 0)));
  for (i = 1; i < 4 * n + 1; i++) {
    cin >> x >> y >> z;
    a.push_back(make_pair(x, make_pair(y, z)));
  }
  for (i = 1; i < 4 * n + 1; i++) visited.insert(i);
  for (i = 1; i < n + 1; i++) ans[i] = 4;
  __typeof(visited.begin()) it = visited.begin();
  while (visited.size() > 0) {
    i = (*it);
    x = a[i].first;
    y = a[i].second.first;
    z = a[i].second.second;
    if ((ans[y] < 9 and z != y and x == z) or
        (ans[z] < 9 and z != y and x == y) or
        (ans[y] < 9 and ans[z] < 9 and z != y and y != x and z != x) or
        (ans[y] < 9 and z == y and z == x) or
        (ans[y] < 8 and z == y and z != x)) {
      ans[y]++;
      ans[z]++;
      ans[x]--;
      final.push_back(i);
      visited.erase(it++);
    } else
      it++;
    if (it == visited.end()) it = visited.begin();
  }
  cout << "YES" << endl;
  for (i = 0; i < final.size(); i++) cout << final[i] << " ";
}
