func_code_string: #include <bits/stdc++.h>   #pragma GCC optimize( Ofast,no-stack-protector,unroll-loops,fast-math )   #pragma GCC target( sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx )   using namespace std;   const long long maxn = 1e5 + 20;   const long long inf = (long long)2e9;   const long double pi = asin(1) * 2;   const long double eps = 1e-8;   const long long mod = (long long)1e9 + 7;   const long long ns = 97;   mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());   long long dp[maxn], tin[maxn], up[maxn], was[maxn], used[maxn];   vector<long long> g[maxn], ans, order;   long long timer = 0, flag = 1;   void dfs(long long v) {     used[v] = 1;     tin[v] = timer++;     dp[v] = tin[up[v]];     for (auto& u : g[v]) {       if (!used[u]) dfs(u);       dp[v] = min(dp[v], dp[u]);       if (dp[u] < tin[v] && dp[u] != tin[up[v]]) flag = 0;     }     if (dp[v] < tin[up[v]]) flag = 0;     order.push_back(v);   }   void dfs2(long long v) {     used[v] = 1;     for (auto& u : g[v])       if (!used[u]) dfs2(u);     if (was[v]) ans.push_back(v);   }   signed main() {     ios_base::sync_with_stdio(false);     cin.tie(nullptr);     cout.tie(nullptr);     long long n, m;     cin >> n >> m;     for (long long i = 0; i < m; ++i) {       long long a, b;       cin >> a >> b;       --a, --b;       g[a].push_back(b);       used[b] = 1;     }     for (long long i = 0; i < n; ++i) {       cin >> up[i];       --up[i];       was[up[i]] = 1;     }     vector<long long> roots;     for (long long i = 0; i < n; ++i)       if (!used[i]) roots.push_back(i);     for (auto& x : used) x = 0;     for (auto& x : roots) dfs(x);     if (!flag) {       cout << -1;       exit(0);     }     for (auto& x : used) x = 0;     reverse(order.begin(), order.end());     for (long long i = 0; i < n; ++i)       if (!used[i]) dfs2(i);     cout << (long long)ans.size() <<   n ;     for (auto& x : ans) cout << x + 1 <<   n ;   }   