#include #include #include #include using std::cout,std::iostream; static const constexpr auto range {std::ranges::views::iota}; static const constexpr int MOD {80112002}, MAX_TYPES {(int)5e3+5} /*, MAX_REL_SHIPS {(int)5e5+5}*/; static int types, rel_ships, a, b, in_degree[MAX_TYPES], out_degree[MAX_TYPES], link_nums[MAX_TYPES], ans; static std::queue q; static std::vector next[MAX_TYPES]; class ReadInt{ char c; int w,n; public: ReadInt &operator>>(int &num){ c=0,w=1,n=0; while(!isdigit(c)){ if(c=='-')w=-1; c = (char)getchar(); } while(isdigit(c)){ n=n*10+(c-'0'); c = (char)getchar(); } num = n*w; return *this; } }; static ReadInt readint; #define cin readint int main(){ cin>>types>>rel_ships; for([[maybe_unused]] const int _:range(1,rel_ships+1)){ cin>>a>>b; next[a].push_back(b); in_degree[b]++; out_degree[a]++; } for(const int i:range(1, types+1)){ if(in_degree[i]==0){ q.push(i); link_nums[i] = 1; } } while(!q.empty()){ auto front {q.front()}; q.pop(); for(auto i:next[front]){ link_nums[i] = (link_nums[i] + link_nums[front])%MOD; if(--in_degree[i]==0){ q.push(i); } } } for(auto i:range(1,types+1)){ if(out_degree[i]==0){ ans = (ans + link_nums[i]) % MOD; } } cout<