写法1;
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define PII pair<int,int>
#define fi first
#define se second
#define inl inline
#define pri priority_queue
using namespace std;
const int maxn=5005;
const int MOD=80112002;
vector<int> edge[maxn];
int in[maxn];
int out[maxn];
int ans[maxn];
int main()
{
IOS;
int n,m;
cin>>n>>m;
for(int i=1;i<=m;i++)
{
int u,v;
cin>>u>>v;
edge[u].pb(v);
in[v]++;
out[u]++;
}
queue<int> q;
for(int i=1;i<=n;i++)
{
if(in[i]==0)
{
q.push(i);
ans[i]=1;
}
}
while(!q.empty())
{
int x=q.front();
q.pop();
for(auto y:edge[x])
{
in[y]--;
ans[y]=(ans[y]+ans[x])%MOD;
if(in[y]==0)
{
q.push(y);
}
}
}
int maxn=0;
for(int i=1;i<=n;i++)
if(out[i]==0) maxn=(maxn+ans[i])%MOD;
cout<<maxn;
}
写法2;
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define PII pair<int,int >;
#define int long long
#define IOS std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e6+5;
int dp[N];
int T,n,m,k;
int in[N];
int out[N];
vector<int>e[N];
void topsort()
{
queue<int> q;
for(int i=1;i<=n;i++)
{
if(in[i]==0)
{
dp[i]=1;
q.push(i);
}
}
while(q.size())
{
auto now=q.front();
q.pop();
for(auto spot:e[now])
{
dp[spot] =(dp[spot]+dp[now])%80112002;
if(--in[spot]==0) q.push(spot);
}
}
}
signed main()
{
IOS;
// dp[i] 代表生产者到i 有多少条不同的路径
cin>>n>>m;
while(m--)
{
int a,b;
cin>>a>>b;
//垃圾的向厉害的建边
e[a].pb(b);
in[b]++;
out[a]++;
}
topsort();
int sum=0;
for(int i=1;i<=n;i++ )if(out[i]==0) sum=(sum+dp[i])%80112002;
cout<<sum;
return 0;
}