#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int inf = 1e9;
int mod = 1e9 + 7;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  int m = 4 * n;
  int a[m], b[m], c[m];
  vector<int> upd[n + 1];
  set<int> s;
  for (int i = 0; i < m; i++) {
    cin >> a[i] >> b[i] >> c[i];
    upd[a[i]].push_back(i);
    upd[b[i]].push_back(i);
    upd[c[i]].push_back(i);
    s.insert(i);
  }
  vector<int> ans;
  vector<bool> done(m, false);
  vector<int> cnt(n + 1, 4);
  function<bool(int)> check = [&](int x) {
    if (b[x] == c[x]) {
      if (a[x] == b[x]) return cnt[a[x]] < 9;
      return cnt[b[x]] < 8;
    } else {
      if (a[x] == b[x]) return cnt[c[x]] < 9;
      if (a[x] == c[x]) return cnt[b[x]] < 9;
      if (cnt[c[x]] == 9 || cnt[b[x]] == 9) return false;
      return true;
    }
  };
  while (!s.empty()) {
    int x = *(s.begin());
    cnt[a[x]]--;
    cnt[b[x]]++;
    cnt[c[x]]++;
    s.erase(x);
    done[x] = true;
    ans.push_back(x);
    for (int u : upd[a[x]]) {
      if (!done[u]) {
        if (check(u))
          s.insert(u);
        else {
          if (s.find(u) != s.end()) s.erase(u);
        }
      }
    }
    for (int u : upd[b[x]]) {
      if (!done[u]) {
        if (check(u))
          s.insert(u);
        else {
          if (s.find(u) != s.end()) s.erase(u);
        }
      }
    }
    for (int u : upd[c[x]]) {
      if (!done[u]) {
        if (check(u))
          s.insert(u);
        else {
          if (s.find(u) != s.end()) s.erase(u);
        }
      }
    }
  }
  cout << "YES\n";
  for (int u : ans) {
    cout << u + 1 << " ";
  }
  cout << "\n";
  return 0;
}
