#include <bits/stdc++.h>
using namespace std;
int n, a, b, c;
map<int, int> ram;
vector<pair<int, pair<int, int> > > rem;
vector<int> order;
vector<int> ans;
bool isIt(int a, int b, int c) {
  return (a == b && a == c && ram[a] <= 8) || (b == c && ram[b] <= 7) ||
         (b != c && ram[b] < 9 && ram[c] < 9);
}
int main() {
  cin >> n;
  for (int I = 0; I < (int)n; I++) ram[I + 1] = 4;
  for (int I = 0; I < (int)4 * n; I++) {
    cin >> a >> b >> c;
    if (isIt(a, b, c))
      ram[a]--, ram[b]++, ram[c]++, ans.push_back(I + 1);
    else
      rem.push_back(pair<int, pair<int, int> >(a, pair<int, int>(b, c))),
          order.push_back(I + 1);
  }
  while (rem.size()) {
    bool can = 0;
    for (int I = 0; I < (int)rem.size(); I++) {
      if (isIt(rem[I].first, rem[I].second.first, rem[I].second.second))
        ram[rem[I].first]--, ram[rem[I].second.first]++,
            ram[rem[I].second.second]++,
            can = can || 1, rem.erase(rem.begin() + I), ans.push_back(order[I]),
            order.erase(order.begin() + I);
      else
        can = can || 0;
    }
    if (!can) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  for (__typeof(ans.begin()) it = ans.begin(); it != ans.end(); it++)
    cout << *it << " ";
  cout << endl;
  return 0;
}
