#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 5000 + 5,mod = 80112002;
ll n, m,ind[N],ans[N];
vector<ll> e[N],fin,sta;
ll dfs(ll st) {
if(ans[st])
return ans[st];
if(st ==*lower_bound(fin.begin(),fin.end(),st)) {
return 1;
}
for (auto p = e[st].begin(); p != e[st].end();p++) {
ll to = *p;
ans[st] += dfs(to);
}
ans[st] %= mod;
return ans[st];
}
int main()
{
cin >> n >> m;
for (int i = 1; i <= m;i++) {
ll fr, to;
cin >> fr >> to;
e[fr].push_back(to);
ind[to]++;
}
for (int i = 1; i <= n;i++) {
if(!ind[i])
sta.push_back(i);
}
for (int i = 1; i <= n;i++) {
if (e[i].empty())
fin.push_back(i);
}
ll anss = 0;
for (auto p = sta.begin(); p != sta.end();p++) {
ll st = *p;
dfs(st);
anss += ans[st];
anss %= mod;
}
printf("%lld", anss);
return 0;
}