#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int reduced;
  vector<pair<int, pair<int, int> > > p(4 * n);
  vector<bool> seen(4 * n, false);
  int count[n + 1];
  fill_n(count, n + 1, 4);
  for (int i = 0; i < 4 * n; i++)
    cin >> p[i].first >> p[i].second.first >> p[i].second.second;
  vector<int> ans;
  int tmp1, tmp2, tmp3;
  do {
    reduced = 0;
    for (int i = 0; i < 4 * n; i++) {
      tmp1 = (p[i].first == p[i].second.first);
      tmp2 = (p[i].first == p[i].second.second);
      tmp3 = (p[i].second.first == p[i].second.second);
      if (!seen[i] and count[p[i].second.first] < 9 + tmp1 and
          count[p[i].second.second] < 9 + tmp2 - tmp3) {
        seen[i] = true;
        ans.push_back(i + 1);
        count[p[i].first]--;
        count[p[i].second.first]++;
        count[p[i].second.second]++;
        reduced++;
      }
    }
  } while (reduced);
  if (ans.size() != 4 * n)
    cout << "NO" << endl;
  else {
    cout << "YES" << endl;
    for (int i = 0; i < ans.size(); i++) cout << ans[i] << ' ';
    cout << endl;
  }
  return 0;
}
