#include <iostream>
using namespace std;
typedef long long LL;
const LL MOD = 80112002;
const int N = 5010;
LL dp[N];
bool ani[N][N];
bool st[N];
int n,m;
LL f(int k){
LL &x = dp[k];
if(x != 0) return x;
for(int i = 1; i <= n; i++){
if(ani[k][i] == 1)
x += f(i);
}
if(x == 0) x = 1;
return x;
}
int main()
{
cin >> n >> m;
while(m--){
int a,b;
cin >> a >> b;
ani[a][b] = 1;
st[b] = true;
}
LL res = 0;
for(int i = 1; i <= n; i++){
if(st[i] == false) res += f(i);
res %= MOD;
}
cout << res;
return 0;
}