func_code_string: #include <bits/stdc++.h>   using namespace std;   int vis[200003], nd, lm, fl, bad[200003];   vector<int> g[200003];   int expo(int y) {     long long x = 2ll, res = 1ll;     while (y) {       if (y & 1) {         res = (res * x);         if (res >= 1000000007) res %= 1000000007;       }       y >>= 1;       x *= x;       if (x >= 1000000007) x %= (long long)1000000007;     }     return (int)res;   }   void dfs(int s, int l) {     vis[s] = 1;     lm = max(l, lm);     bad[s] = 1;     if (!vis[g[s][0]]) {       dfs(g[s][0], l + 1);     } else if (vis[g[s][0]] && bad[g[s][0]]) {       nd = g[s][0];       fl = 1;     }     bad[s] = 0;   }   int main() {     int n;     scanf( %d , &(n));     for (int(i) = (0); (i) < (n); (i)++) {       int x;       scanf( %d , &(x));       g[i + 1].push_back(x);     }     memset(vis, 0, sizeof(vis));     int cnt = 0;     long long ans = 1ll;     for (int i = 1; i <= n; ++i) {       if (vis[i]) continue;       fl = 0;       dfs(i, 1);       if (!fl) continue;       lm = 1;       int node = g[nd][0];       while (node != nd) {         node = g[node][0];         ++lm;       }       ans *= (long long)expo(lm) - 2ll;       if (ans >= 1000000007) ans %= (long long)1000000007;       cnt += lm;     }     ans *= (long long)expo(n - cnt);     ans %= (long long)1000000007;     printf( %d n , (int)ans);     return 0;   }   