#include using namespace std; #define ALL(x) begin(x),end(x) #define rep(i,n) for(int i=0;i<(n);i++) #define debug(v) cout<<#v<<":";for(auto x:v){cout<bool chmax(T &a,const T &b){if(abool chmin(T &a,const T &b){if(b ostream &operator<<(ostream &os,const vector&v){ for(int i=0;i<(int)v.size();i++) os< istream &operator>>(istream &is,vector&v){ for(T &x:v)is>>x; return is; } signed main(){ int n,m;ll t;cin>>n>>m>>t; using M=vector>; using V=vector; M g(n,vector(n,0)); rep(i,m){ int u,v;cin>>u>>v; g[u][v]=1; } auto f=[&](M a,M b){ M ret(n,V(n,0)); rep(k,n){ rep(i,n){ rep(j,n){ if(a[i][k] and b[k][j]) ret[i][j]=1; } } } return ret; }; V unko(n,0); unko[0]=1; while(t){ if(t&1){ V nx(n,0); rep(i,n)rep(j,n){ if(unko[i] and g[i][j]) nx[j]=1; } swap(unko,nx); } g=f(g,g); t/=2; } int res=0; for(auto x:unko) res+=x; cout<