#include <bits/stdc++.h>
using namespace std;
template <class T>
void debug(T a, T b) {
  ;
}
template <class T>
void chmin(T& a, const T& b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T& a, const T& b) {
  if (a < b) a = b;
}
namespace std {
template <class S, class T>
ostream& operator<<(ostream& out, const pair<S, T>& a) {
  out << '(' << a.first << ',' << a.second << ')';
  return out;
}
}  // namespace std
long long int readL() {
  long long int res;
  scanf("%I64d", &res);
  return res;
}
void printL(long long int res) { printf("%I64d", res); }
int n;
vector<pair<pair<int, int>, int> > g[30005];
int pot[30005];
int main() {
  cin >> n;
  for (int i = 0; i < (n * 4); ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    --a;
    --b;
    --c;
    g[a].push_back(make_pair(make_pair(b, c), i));
  }
  vector<int> res;
  for (int i = 0; i < (n); ++i) pot[i] = 8;
  set<int> less9;
  for (int i = 0; i < (n); ++i) less9.insert(i);
  for (int hoge = 0; hoge < (n * 4); ++hoge) {
    auto it = less9.begin();
    while (it != less9.end()) {
      int v = *it;
      if (!g[v].empty()) {
        int b = g[v].back().first.first, c = g[v].back().first.second;
        res.push_back(g[v].back().second);
        ++pot[v];
        --pot[b];
        --pot[c];
        if (pot[v] == 9) less9.erase(it);
        if (pot[b] < 9) less9.insert(b);
        if (pot[c] < 9) less9.insert(c);
        g[v].pop_back();
        break;
      } else {
        less9.erase(it++);
      }
    }
    if (it == less9.end()) {
      while (1) {
      };
    }
  }
  reverse((res).begin(), (res).end());
  puts("YES");
  for (int i = 0; i < (n * 4); ++i) printf("%d\n", res[i] + 1);
  return 0;
}
