func_code_string: #include <bits/stdc++.h>   using namespace std;   int Get() {     char c;     while (c = getchar(), c <  0  || c >  9 )       ;     int X = c - 48;     while (c = getchar(), c >=  0  && c <=  9 ) X = X * 10 + c - 48;     return X;   }   int Pow(int A, int B, int Mod) {     if (!B) return 1;     int T = Pow((long long)A * A % Mod, B / 2, Mod);     if (B & 1) T = (long long)T * A % Mod;     return T;   }   int main() {     int N = Get(), M = Get(), Mod = Get();     static int G[600][600], In[600], Out[600];     memset(G, 0, sizeof(G));     memset(In, 0, sizeof(In));     memset(Out, 0, sizeof(Out));     for (int i = 0; i < M; i++) {       int X = Get() - 1, Y = Get() - 1;       G[X][Y]++;       In[Y]++;       Out[X]++;     }     static vector<int> List[600];     for (int i = 0; i < N; i++)       for (int j = 0; j < N; j++)         if (G[i][j]) List[i].push_back(j);     static int Temp[600], Stack[600];     int Top = 0;     for (int i = 0; i < N; i++) {       Temp[i] = In[i];       if (!Temp[i]) Stack[Top++] = i;     }     static int Queue[600];     int Count = 0;     while (Top--) {       int V = Stack[Top];       Queue[Count++] = V;       for (int i = 0; i < N; i++)         if (G[V][i]) {           Temp[i] -= G[V][i];           if (!Temp[i]) Stack[Top++] = i;         }     }     static int P[600][600];     memset(P, 0, sizeof(P));     for (int i = 0; i < N; i++) {       int V = Queue[i];       P[V][V] = 1;       for (int j = i; j < N; j++) {         int U = Queue[j];         if (!P[V][U]) continue;         for (int k = 0; k < List[U].size(); k++) {           int _U = List[U][k];           P[V][_U] = ((long long)P[V][U] * G[U][_U] + P[V][_U]) % Mod;         }       }     }     int K0 = 0, K1 = 0;     static int X[600], Y[600];     for (int i = 0; i < N; i++) {       if (!In[i] && Out[i]) X[K0++] = i;       if (!Out[i] && In[i]) Y[K1++] = i;     }     int K = K0;     static long long A[600][600];     for (int i = 0; i < K; i++)       for (int j = 0; j < K; j++) A[i][j] = P[X[i]][Y[j]];     int Ans = 1;     for (int i = 0; i < N; i++)       if (!In[i] && !Out[i]) X[K0++] = Y[K1++] = i;     for (int i = 0; i < K0; i++)       for (int j = 0; j < K0; j++)         if (X[i] < X[j] && Y[i] > Y[j]) Ans = -Ans;     for (int i = 0; i < K; i++) {       int P = i;       while (P < K && !A[P][i]) P++;       if (P == K) {         printf( 0 n );         return 0;       }       if (P != i) {         Ans = -Ans;         for (int j = i; j < K; j++) swap(A[i][j], A[P][j]);       }       int Q = Pow(A[i][i], Mod - 2, Mod);       for (int j = i + 1; j < K; j++) {         int T = (long long)A[j][i] * Q % Mod;         if (!T) continue;         for (int k = i; k < K; k++) {           A[j][k] = (A[j][k] - (long long)T * A[i][k]) % Mod;           if (A[j][k] < 0) A[j][k] += Mod;         }       }     }     for (int i = 0; i < K; i++) Ans = (long long)Ans * A[i][i] % Mod;     if (Ans < 0) Ans += Mod;     printf( %d n , Ans);     return 0;   }   