#include using namespace std; #include using namespace atcoder; using mint=modint998244353; //1000000007; using ll=long long; using pp=pair; #define sr string #define vc vector #define fi first #define se second #define rep(i,n) for(ll i=0;i<(ll)n;i++) #define pb push_back #define all(v) v.begin(),v.end() #define pque priority_queue #define bpc(a) __builtin_popcount(a) // https://youtu.be/ylWYSurx10A?t=2352 template struct Matrix { int h, w; vector> d; Matrix() {} Matrix(int h, int w, T val=0): h(h), w(w), d(h, vector(w,val)) {} Matrix& unit() { assert(h == w); rep(i,h) d[i][i] = 1; return *this; } const vector& operator[](int i) const { return d[i];} vector& operator[](int i) { return d[i];} Matrix operator*(const Matrix& a) const { assert(w == a.h); Matrix r(h, a.w); rep(i,h)rep(k,w)rep(j,a.w) { r[i][j] |= d[i][k]*a[k][j]; } return r; } Matrix pow(long long t) const { assert(h == w); if (!t) return Matrix(h,h).unit(); if (t == 1) return *this; Matrix r = pow(t>>1); r = r*r; if (t&1) r = r*(*this); return r; } // https://youtu.be/-j02o6__jgs?t=11273 /* mint only mint det() { assert(h == w); mint res = 1; rep(k,h) { for (int i = k; i < h; ++i) { if (d[i][k] == 0) continue; if (i != k) { swap(d[i],d[k]); res = -res; } } if (d[k][k] == 0) return 0; res *= d[k][k]; mint inv = mint(1)/d[k][k]; rep(j,h) d[k][j] *= inv; for (int i = k+1; i < h; ++i) { mint c = d[i][k]; for (int j = k; j < h; ++j) d[i][j] -= d[k][j]*c; } } return res; } //*/ }; int main(){ int n,m; ll t;cin>>n>>m>>t; Matrixv(n,n); rep(i,m){ int a,b;cin>>a>>b; v[b][a]=1; } v=v.pow(t); int ans=0; rep(i,n)ans+=v[i][0]; cout<