func_code_string: #include <bits/stdc++.h>   struct node {     int x, y, next;   } e[100861];   int head[100861], book[100861] = {0}, b[100861];   int main() {     memset(head, -1, sizeof(head));     int n, m, a;     scanf( %d%d , &n, &m);     for (int i = 1; i <= m; i++) {       scanf( %d%d , &e[i].x, &e[i].y);       e[i].next = head[e[i].x];       head[e[i].x] = i;       book[e[i].y]++;     }     int sum = 0, flag = 1, maxx = 0, f;     for (int i = 1; i <= n; i++)       if (book[i] == 0) {         b[sum++] = i;       }     if (sum != 1) flag = 0;     for (int i = 0; i < sum; i++) {       int num = 0;       for (int j = head[b[i]]; j != -1; j = e[j].next) {         book[e[j].y]--;         if (book[e[j].y] == 0) {           b[sum++] = e[j].y;           num++;           if (j > maxx) maxx = j;         }       }       if (num > 1) flag = 0;     }     if (flag == 0 || sum < n)       printf( -1 n );     else       printf( %d n , maxx);     return 0;   }   