#include using namespace std; using ll = long long; using ld = long double; #define all(s) (s).begin(),(s).end() #define vcin(n) for(ll i=0;i>n[i] #define rever(vec) reverse(vec.begin(), vec.end()) #define sor(vec) sort(vec.begin(), vec.end()) #define fi first #define se second const ll mod = 998244353; //const ll mod = 1000000007; const ll inf = 2000000000000000000ll; static const long double pi = 3.141592653589793; template void chmax(T& t,const U& u){if(t void chmin(T& t,const U& u){if(t>u) t=u;} ll modPow(ll a, ll n, ll mod) { ll ret = 1; ll p = a % mod; while (n) { if (n & 1) ret = ret * p % mod; p = p * p % mod; n >>= 1; } return ret; } vector> multi(vector> a, vector> b){ ll n = a.size(); vector> res(n, vector(n, 0)); for (ll i = 0; i < n; ++i){ for (ll j = 0; j < n; ++j){ for (ll x = 0; x < n; ++x){ res[i][j] = ((res[i][j]) | (a[i][x] & b[x][j])) % mod; } } } return res; } vector> mul_exp(vector> adj, ll k, ll n){ if (k == 0){ vector> d(n,vector(n)); for(int i=0;i> res = mul_exp(adj, k / 2, n); if (k % 2 == 0) return multi(res, res); else return multi(adj, multi(res, res)); } int main() { /* mod は 1e9+7 */ ios::sync_with_stdio(false); std::cin.tie(nullptr); cout<< fixed << setprecision(10); ll n,m,t; cin>>n>>m>>t; vector> dp(n,vector(n)); for(int i=0;i>x>>y; dp[y][x]=1; } auto ans=mul_exp(dp,t,n); ll ansi=0; for(int i=0;i