#include <bits/stdc++.h>
using namespace std;
struct edge
{
long long v, nxt;
} e[(int)5e5 + 10];
long long f[(int)5e3 + 10], cnt, u, v, n, m, in[(int)5e3 + 10];
unsigned long long p[(int)5e3 + 10],ans;
queue<int> q;
void ins(int u, int v)
{
e[++cnt] = {v, f[u]};
f[u] = cnt;
}
void topo()
{
for (int i = 1; i <= n; i++)
{
if (in[i] == 0)
{
q.push(i);
p[i] = 1;
}
}
while (!q.empty())
{
int u = q.front();
q.pop();
for (int i = f[u]; i; i = e[i].nxt)
{
int v = e[i].v;
p[v] += p[u]%80112002;//注意这里不模会错6个点
if (--in[v] == 0)
{
q.push(v);
}
if (f[v] == 0)
{
ans+=p[u]%80112002;
ans %= 80112002;
}
}
}
cout << ans;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n >> m;
for (int i = 1; i <= m; i++)
{
cin >> u >> v;
ins(u, v);
in[v]++;
}
topo();
return 0;
}
能模的地方就模一下(确信