func_code_string: #include <bits/stdc++.h>   using namespace std;   struct node {     int u, v;   };   node p[200010];   int du[200010], n, m;   int _first[200010], _next[200010], _to[200010], cnt;   int add(int a, int b) {     _next[++cnt] = _first[a];     _first[a] = cnt;     _to[cnt] = b;     du[b]++;   }   bool check(int x) {     cnt = 0;     bool ok = 1;     int now;     for (int i = 1; i <= n; i++) du[i] = 0, _first[i] = 0;     for (int i = 1; i <= x; i++) add(p[i].u, p[i].v);     for (int i = 1; i <= n; i++) {       if (!ok && !du[i]) return false;       if (!du[i]) now = i, ok = 0;     }     if (ok) return false;     while (_first[now]) {       ok = 1;       for (int i = _first[now]; i; i = _next[i]) {         du[_to[i]]--;         if (!ok && !du[_to[i]]) return false;         if (!du[_to[i]]) now = _to[i], ok = 0;       }     }     return true;   }   int main() {     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d%d , &p[i].u, &p[i].v);       if (p[i].u == 0 || p[i].v == 0) return 0;     }     int l = 1, r = m, ans = -1;     while (l <= r) {       int mid = (l + r) / 2;       if (check(mid))         ans = mid, r = mid - 1;       else         l = mid + 1;     }     printf( %d , ans);     return 0;   }   