func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 600 + 5;   const int M = 2e5 + 5;   template <class T>   inline void getin(T& num) {     char c;     bool flag = 0;     num = 0;     while ((c = getchar()) <  0  || c >  9 )       if (c ==  - ) flag = 1;     while (c >=  0  && c <=  9 ) {       num = num * 10 + c - 48;       c = getchar();     }     if (flag) num = -num;   }   int n, m, u, v, In[N];   int tot, x[N], y[N], Out[N];   int cnt, fir[N], tar[M], nxt[M];   long long p, f[N][N], a[N][N];   inline void link(int a, int b) {     tar[++cnt] = b, In[b]++, Out[a]++;     nxt[cnt] = fir[a], fir[a] = cnt;   }   template <class T>   inline void add(T& a, T b) {     a += b;     if (a >= p) a -= p;   }   inline void Dp() {     queue<int> q;     int c = 0;     for (int i = 1; i <= n; i++) {       if (!In[i]) x[++tot] = i;       if (!Out[i]) y[++c] = i;     }     for (int i = 1; i <= n; i++) f[i][i] = 1;     for (int i = 1; i <= n; i++)       if (!In[i]) q.push(i);     while (!q.empty()) {       int u = q.front();       q.pop();       for (int i = fir[u]; i; i = nxt[i]) {         int v = tar[i];         for (int i = 1; i <= n; i++) add(f[i][v], f[i][u]);         In[v]--;         if (!In[v]) q.push(v);       }     }     for (int i = 1; i <= tot; i++)       for (int j = 1; j <= tot; j++) a[i][j] = f[x[i]][y[j]];   }   inline int calc(int n) {     int ret = 1;     for (int i = 1; i <= n; i++) {       if (a[i][i] < 0) {         ret = -ret;         for (int k = i; k <= n; k++) a[i][k] = -a[i][k];       }       for (int j = i + 1; j <= n; j++) {         for (int k = i; k <= n; k++) a[i][k] %= p, a[j][k] %= p;         while (a[j][i]) {           if (a[j][i] < 0) {             ret = -ret;             for (int k = i; k <= n; k++) a[j][k] = -a[j][k];           }           int t = a[i][i] / a[j][i];           for (int k = i; k <= n; k++) a[i][k] = (a[i][k] - t * a[j][k]) % p;           for (int k = i; k <= n; k++) swap(a[i][k], a[j][k]);           ret = -ret;         }       }       if (a[i][i] == 0) return 0;       ret = 1ll * ret * a[i][i] % p;     }     return (ret + p) % p;   }   int main() {     getin(n), getin(m), getin(p);     for (int i = 1; i <= m; i++) getin(u), getin(v), link(u, v);     Dp();     cout << calc(tot) <<   n ;   }   