#include <bits/stdc++.h>
using namespace std;
const int maxn = 30010;
int c[maxn] = {};
vector<int> ans;
vector<pair<pair<int, int>, int> > v[maxn];
priority_queue<pair<int, int> > q;
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < 4 * n; ++i) {
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    v[a].push_back(pair<pair<int, int>, int>(pair<int, int>(b, c), i + 1));
  }
  for (int i = 1; i <= n; ++i) q.push(pair<int, int>(c[i], i));
  puts("YES");
  while (q.size()) {
    pair<int, int> t = q.top();
    q.pop();
    int x = t.second;
    if (v[x].size() == 0 || c[x] != t.first) continue;
    int a = v[x].back().first.first, b = v[x].back().first.second,
        i = v[x].back().second;
    v[x].pop_back();
    c[x]--;
    c[a]++;
    c[b]++;
    q.push(pair<int, int>(c[x], x));
    q.push(pair<int, int>(c[a], a));
    q.push(pair<int, int>(c[b], b));
    ans.push_back(i);
  }
  reverse(ans.begin(), ans.end());
  for (int x : ans) printf("%d ", x);
  puts("");
  return 0;
}
