#include <bits/stdc++.h>
using namespace std;
void task();
int main() {
  ios_base::sync_with_stdio(0);
  int x = clock();
  task();
  return 0;
}
struct Rule {
  int id, from, t1, t2;
  Rule(int id, int from, int t1, int t2) : id(id), from(from), t1(t1), t2(t2) {}
};
vector<int> state;
void apply(const Rule& r) {
  --state[r.from];
  ++state[r.t1];
  ++state[r.t2];
}
void undo(const Rule& r) {
  ++state[r.from];
  --state[r.t1];
  --state[r.t2];
}
bool check(const Rule& r) { return state[r.t1] < 10 && state[r.t2] < 10; }
void task() {
  int n;
  cin >> n;
  vector<int> ans(0);
  state.assign(n, 4);
  queue<Rule> Q;
  bool fl = true;
  for (int i = 1; i < 4 * n + 1; ++i) {
    int x, t1, t2;
    cin >> x >> t1 >> t2;
    --x;
    --t1;
    --t2;
    Q.push(Rule(i, x, t1, t2));
  }
  while (fl && !Q.empty()) {
    int size = Q.size();
    for (int i = 0; i < size; ++i) {
      Rule cur = Q.front();
      Q.pop();
      apply(cur);
      if (check(cur)) {
        ans.push_back(cur.id);
        continue;
      } else {
        undo(cur);
        Q.push(cur);
      }
    }
    fl = Q.size() < size;
  }
  if (fl) {
    cout << "YES" << endl;
    for (auto& a : (ans)) cout << a << ' ';
  } else
    cout << "NO";
}
