#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
constexpr int N = 1e7, mod = 80112002;
int ne[N], h[N], e[N], idx;
int in[N], out[N], dp[N]; // dp数组表示到达i的从起点出发的路径数;
int n, m;
inline void add(int a, int b)
{
e[idx] = b;
ne[idx] = h[a];
h[a] = idx++;
}
int ans = 0;
void topology()
{
queue<int> q;
for (int i = 1; i <= n; i++)
{
if (in[i] == 0)
{
dp[i] = 1; // 即这条路已经有一条链了;
q.push(i);
}
}
while (q.size())
{
int now = q.front();
q.pop();
for (int i = h[now]; i != -1; i = ne[i])
{
int j = e[i];
dp[j] += dp[now]; // 到j的路径包含到now的路径;
dp[j] %= mod;
in[j]--;
if (in[j] == 0)
{
if (out[j] == 0)
{
ans += dp[j];//到达终点j的时候,更新ans;ans包含了到达j的所有路径
ans %= mod;
}
q.push(j);
}
}
}
}
int main()
{
memset(h, -1, sizeof h);
cin >> n >> m;
for (int i = 0; i < m; i++)
{
int a, b;
cin >> a >> b;
out[a]++;
in[b]++;
add(a, b);
}
topology();
cout << ans << endl;
return 0;
}