#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
int n;
vector<int> ans;
int a[N];
vector<int> v[N];
bool vis[N];
void dfs(int pos) {
  vis[pos] = 1;
  ans.push_back(pos);
  for (auto &i : v[a[pos]])
    if (!vis[i]) {
      dfs(i);
      break;
    }
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  int t1, t2, t3;
  for (int i = 1; i <= n * 4; i++) {
    cin >> t1 >> t2 >> t3;
    a[i] = t1;
    v[t2].push_back(i);
    v[t3].push_back(i);
  }
  for (int i = 1; i <= n * 4; i++)
    if (!vis[i]) dfs(i);
  reverse(ans.begin(), ans.end());
  cout << "YES" << endl;
  for (auto &i : ans) cout << i << ' ';
  return 0;
}
