func_code_string: #include <bits/stdc++.h>   int read() {     int x = 0, f = 1;     char ch = getchar();     while (ch <  0  || ch >  9 ) {       if (ch ==  - ) f = -1;       ch = getchar();     }     while (ch >=  0  && ch <=  9 ) {       x = x * 10 + ch -  0 ;       ch = getchar();     }     return x * f;   }   using namespace std;   bool b[100000 + 5];   vector<int> v[100000 + 5];   int n, m;   int s[100000 + 5];   int ans[100000 + 5], cnt = 0;   bool yes = true;   void dfs(int x, int fa) {     if (fa != 0 && s[x] != x && s[x] != s[fa]) {       puts( -1 );       yes = false;     }     if (s[x] == x) ans[++cnt] = x;     for (int i = 0; i < v[x].size(); i++) {       int y = v[x][i];       if (y == fa) continue;       dfs(y, x);     }   }   int main() {     n = read();     m = read();     for (int i = 1; i <= m; i++) {       int x = read(), y = read();       v[x].push_back(y);       b[y] = 1;     }     for (int i = 1; i <= n; i++) s[i] = read();     for (int i = 1; i <= n; i++) {       if (!b[i]) dfs(i, 0);     }     if (yes == true) {       cout << cnt << endl;       for (int i = cnt; i >= 1; i--) {         cout << ans[i] << endl;       }     }     return 0;   }   