#include #include using namespace std; #define rep(i,n) for (int i = 0; i < (n); ++i) #define Inf 1000000000 template struct matrix{ F0 func0; F1 func1; vector> value; int height,width; T init_value0,init_value1; matrix(vector> X,F0 f0,F1 f1,T iv0,T iv1):func0(f0),func1(f1){ height = X.size(); width = X[0].size(); value = X; init_value0 = iv0,init_value1 = iv1; } matrix(int h,int w,F0 f0,F1 f1,T iv0,T iv1):func0(f0),func1(f1){ vector> d(h,vector(w,iv0)); height = h,width = w; value = d; init_value0 = iv0,init_value1 = iv1; } void set_1(){ for(int i=0;i R(height,another.width,func0,func1,init_value0,init_value1); for(int i=0;i R(height,width,func0,func1,init_value0,init_value1); R.set_1(); auto temp = *this; while(cnt!=0LL){ if(cnt%2==1){ R *= temp; } temp *= temp; cnt/=2; } return R; } }; int main(){ int N,M; cin>>N>>M; long long T; cin>>T; vector> A(N+1,vector(N+1,0)); rep(i,M){ int a,b; cin>>a>>b; A[a][b] = 1; } rep(i,N){ A[i][N] = 1; A[N][N] = 1; } auto f0 = [](int a,int b){ return a|b; }; auto f1 = [](int a,int b){ return a&b; }; matrix AA(A,f0,f1,0LL,1); AA = AA.beki(T); vector> X(1,vector(N+1,1)); matrix XX(X,f0,f1,0LL,1); XX *= AA; int ans= 0; rep(i,N){ ans += XX.value[0][i]; } cout<