#include <bits/stdc++.h>
using namespace std;
struct rul {
  int a, b, c, usd;
};
struct inc {
  int id;
  inc(int a = 0) { id = a; }
};
int n;
set<int> avb;
vector<vector<inc> > crs;
vector<int> cfl;
vector<rul> ruls;
int coc;
vector<int> lco;
vector<int> tm;
void lkat(int id) {
  if (ruls[id].usd) return;
  if (lco[id] == coc) return;
  int& a = ruls[id].a;
  int& b = ruls[id].b;
  int& c = ruls[id].c;
  tm[a] = cfl[a];
  tm[b] = cfl[b];
  tm[c] = cfl[c];
  tm[a]--;
  tm[b]++;
  tm[c]++;
  bool isok = 1;
  if (tm[b] > 9 || tm[c] > 9) isok = 0;
  if (isok)
    avb.insert(id);
  else {
    if (avb.count(id)) avb.erase(id);
  }
}
void tfr(rul cc) {
  ++coc;
  cfl[cc.a]--;
  cfl[cc.b]++;
  cfl[cc.c]++;
  for (int i = 0; i < ((int((crs[cc.a]).size()))); ++i) lkat(crs[cc.a][i].id);
  for (int i = 0; i < ((int((crs[cc.b]).size()))); ++i) lkat(crs[cc.b][i].id);
  for (int i = 0; i < ((int((crs[cc.c]).size()))); ++i) lkat(crs[cc.c][i].id);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  crs.resize(n);
  cfl.resize(n, 4);
  ruls.resize(n * 4);
  lco.resize(4 * n + 9, -1);
  tm.resize(4 * n + 9);
  coc = 0;
  for (int i = 0; i < (n * 4); ++i) {
    ruls[i].usd = 0;
    cin >> ruls[i].a >> ruls[i].b >> ruls[i].c;
    ruls[i].a--;
    ruls[i].b--;
    ruls[i].c--;
    crs[ruls[i].a].push_back(inc(i));
    crs[ruls[i].b].push_back(inc(i));
    crs[ruls[i].c].push_back(inc(i));
    avb.insert(i);
  }
  cout << "YES\n";
  for (int zz = 0; zz < (n * 4); ++zz) {
    assert(!avb.empty());
    int cc = *avb.begin();
    avb.erase(avb.begin());
    cout << (cc + 1) << (zz + 1 == 4 * n ? "\n" : " ");
    ruls[cc].usd = 1;
    tfr(ruls[cc]);
  }
  return 0;
}
