func_code_string: #include <bits/stdc++.h>   using namespace std;   const int MAXN = 1e5 + 10;   int a[MAXN];   bool mark[MAXN];   void add(int v, int u) {     while (mark[u] == false) {       cout << v <<     << u << endl;       mark[u] = true;       v = a[v];       u = a[u];     }   }   int dfs(int x) {     int ret = 1;     mark[x] = true;     if (mark[a[x]] == false) ret += dfs(a[x]);     return ret;   }   int main() {     ios::sync_with_stdio(false);     int n;     cin >> n;     for (int i = 1; i <= n; i++) cin >> a[i];     for (int i = 1; i <= n; i++)       if (a[i] == i) {         cout <<  YES  << endl;         for (int j = 1; j <= n; j++)           if (j != i) cout << i <<     << j << endl;         return 0;       }     int p = -1;     for (int i = 1; i <= n; i++)       if (mark[i] == false) {         int x = dfs(i);         if (x % 2) {           cout <<  NO  << endl;           return 0;         } else if (x == 2)           p = i;       }     if (p == -1) {       cout <<  NO  << endl;       return 0;     }     fill(mark, mark + MAXN, false);     cout <<  YES  << endl;     cout << p <<     << a[p] << endl;     mark[p] = mark[a[p]] = true;     for (int i = 1; i <= n; i++)       if (!mark[i]) add(p, i);     return 0;   }   