#include <bits/stdc++.h>
using namespace std;
int m,n;
struct dot{
int r,c;
vector <int> ljb;
}dots[5003];
int dfs(int id);
int x,y;
long long answer;
int main(){
cin>>n>>m;
for(int i=1;i<=m;i++){
cin>>x>>y;
dots[x].c++,dots[y].r++;
dots[x].ljb.push_back(y);
}
answer=dfs(1);
cout<<answer%80112002;
}
int dfs(int id){
if(dots[id].c==0) return 1;
else {
int ans=0;
for(int i=0;i<dots[id].c;i++) ans+=dfs(dots[id].ljb[i]);
return ans;
}
}