#include using namespace std; typedef long long ll; typedef vector vi; typedef vector vl; typedef complex P; typedef pair pii; #define REP(i,n) for(ll i=0;i> n >> m; vector G(n,vi(n,1)); REP(i,m){ int a,b; cin >> a >> b; --a;--b; G[a][b] = 0; } int beg=-1,end=-1; REP(i,n){ int in = 0, out = 0; REP(j,n){ if(G[i][j]==1)in += 1; if(G[j][i]==1)out += 1; } if(in==out)continue; if(in+1==out){ if(beg==-1){ beg = i; continue; } } if(in==out+1){ if(end==-1){ end = i; continue; } } cout << 0 << endl; return 0; } if(n*n==m){ cout << 1 << endl; return 0; } cout << n*n << endl; return 0; }