#include <bits/stdc++.h>
using namespace std;
const int N = 3e4 + 100;
vector<int> g[N], idx[N];
int adj_used[N];
vector<int> circuit;
void euler(int u, int id = -1) {
  while (adj_used[u] < g[u].size()) {
    int v = g[u][adj_used[u]++];
    euler(v, idx[u][adj_used[u] - 1]);
  }
  if (id != -1) circuit.push_back(id);
}
void find_circuit(int n) {
  for (int i = 1; i <= n; i++) {
    int cnt = 0;
    for (int j = 0; j < g[i].size(); j++) {
      if (g[i][j] == i) {
        swap(g[i][j], g[i][cnt]);
        swap(idx[i][j], idx[i][cnt]);
        cnt++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (adj_used[i] < g[i].size()) {
      euler(i);
    }
  }
  reverse(circuit.begin(), circuit.end());
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i <= 4 * n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    g[a].push_back(b);
    g[a].push_back(c);
    idx[a].push_back(i);
    idx[a].push_back(i);
  }
  find_circuit(n);
  vector<int> found(4 * n + 1);
  vector<int> res;
  for (auto x : circuit) {
    if (found[x]) res.push_back(x);
    found[x] = true;
  }
  cout << "YES" << endl;
  for (auto x : res) {
    cout << x << " ";
  }
  return 0;
}
