#include<bits/stdc++.h>
using namespace std;
const long long mod = 80112002;
const int N = 5005;
int ans[N];
int maxn,n,m,q,b;
bool topy[N], fronty[N];
short s[N][N];
int dfs(int i)
{
if (ans[i] != -1) return ans[i]%mod;
if (!fronty[i] && !topy[i])
{
ans[i] = 0;
return 0;
}
if (!fronty[i])
{
ans[i] = 1;
return 1;
}
ans[i] = 0;
for (int j = 1; j <= s[i][0]; j++)ans[i] = (ans[i]+max(1, dfs(s[i][j])))%mod;
return ans[i]%mod;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
memset(ans, -1, N);
cin >> n>>m;
while (m-- && cin >> q >> b)
{
topy[q] = 1;
fronty[b] = 1;
s[b][++s[b][0]] = q;
}
for (int i = 1; i <= n; i++)
{
if (!topy[i]) maxn += dfs(i)%mod;
maxn %= mod;
}
cout << maxn%mod;
return 0;
}