#include #define REP(i,n) for(int i=0,i##_len=int(n);i=-_mod)_num=_mod+_num; else _num=_mod-(-_num)%_mod; } else if(_num>=_mod) _num%=_mod; return *this; } ll imod()const{ ll n=_mod-2; ll ans = 1,x=_num; while(n != 0){ if(n&1) ans = ans*x%_mod; x = x*x%_mod; n = n >> 1; } return ans; } public: explicit mint(){ _num = 0; } explicit mint(ll num){ _num = num; if(_num<0){ if(_num>=-_mod)_num=_mod+_num; else _num=_mod-(-_num)%_mod; } else if(_num>=_mod) _num%=_mod; } explicit mint(ll num,ll M){ _mod=M; _num=num; if(_num<0){ if(_num>=-_mod)_num=_mod+_num; else _num=_mod-(-_num)%_mod; } else if(_num>=_mod) _num%=_mod; } mint(const mint &cp){_num=cp._num;_mod=cp._mod;} mint operator+ (const mint &x)const{ return mint(_num + x._num , _mod); } mint operator- (const mint &x)const{ return mint(_num - x._num , _mod);} mint operator* (const mint &x)const{ return mint(_num * x._num , _mod); } mint operator/ (const mint &x)const{ return mint(_num * x.imod() , _mod);} mint operator+=(const mint &x){ return set(_num + x._num); } mint operator-=(const mint &x){ return set(_num - x._num); } mint operator*=(const mint &x){ return set(_num * x._num); } mint operator/=(const mint &x){ return set(_num * x.imod());} mint operator= (const ll x){ return set(x); } mint operator+ (const ll x)const{return *this + mint(x,_mod); } mint operator- (const ll x)const{ return *this - mint(x,_mod); } mint operator* (const ll x)const{ return *this * mint(x,_mod); } mint operator/ (const ll x)const{ return *this/mint(x, _mod);} mint operator+=(const ll x){ *this = *this + x;return *this; } mint operator-=(const ll x){ *this = *this - x;return *this; } mint operator*=(const ll x){ *this = *this * x;return *this;} mint operator/=(const ll x){ *this = *this / x;return *this;} bool operator==(const mint &x)const{return _num==x._num;} bool operator!=(const mint &x)const{return _num!=x._num;} friend mint operator+(ll x,const mint &m){return mint(m._num + x , m._mod);} friend mint operator-(ll x,const mint &m){return mint( x - m._num , m._mod);} friend mint operator*(ll x,const mint &m){return mint(m._num * (x % m._mod) , m._mod);} friend mint operator/(ll x,const mint &m){return mint(m.imod() * (x % m._mod) , m._mod);} explicit operator ll() { return _num; } explicit operator int() { return (int)_num; } friend std::ostream& operator<<(std::ostream &os, const mint &x){ os << x._num; return os; } friend std::istream& operator>>(std::istream &is, mint &x){ll val; is>>val; x.set(val); return is;} }; template class MAT{ private: int row,col; vector> _A; double eps = 1e-9; MAT set(vector> A){_A = A ; return *this;} public: MAT(){ } MAT(int n,int m=0,T x=T(0)){ if(n<1 || m<0){cout << "err Matrix::Matrix" < a(col,x); _A.push_back(a); } if(m==0) REP(i,n) _A[i][i]=1.0; } MAT(vector> A){row=A.size();col=A[0].size();_A=A;} MAT(const MAT &cp){_A=cp._A;row=cp.row;col=cp.col;} T* operator[] (int i){return _A[i].data();} MAT operator= (vector> x) {return set(x);} MAT operator+ (MAT x) const { if(row!=x.row || col!=x.col){ cerr << "err Matrix::operator+" <>(){return _A;} friend ostream &operator<<(ostream &os,const MAT &x){ REP(i,x.row) REP(j,x.col) os<>(istream &is,MAT &x){REP(i,x.row) REP(j,x.col) is>>x._A[i][j];return is;} size_t size_row()const{return row;} size_t size_col()const{return col;} MAT transpose()const{ MAT r(col,row); REP(i,col) REP(j,row) r[i][j]=_A[j][i]; return r; } MAT inverse()const{ T buf; MAT inv_a(row,0); vector> a=_A; //row reduction REP(i,row){ buf=1/a[i][i]; REP(j,row){ a[i][j]*=buf; inv_a[i][j]*=buf; } REP(j,row){ if(i!=j){ buf=a[j][i]; REP(k,row){ a[j][k]-=a[i][k]*buf; inv_a[j][k]-=inv_a[i][k]*buf; } } } } return inv_a; } MAT Jacobi(MAT b)const{//ヤコビ法によって解を求める size_t sz=row; MAT D(sz,sz),inD(sz,sz),H(sz,sz),N(sz,sz); MAT c(sz,1),x(sz,1),tmp(sz,1); //cout<<"initialized"< DL(row),U(row),inDL(row),H(row),c(row,1),x(row,1),tmp(row,1); for(int i=0;i=j){ DL[i][j] = _A[i][j]; U[i][j] = 0; } else{ DL[i][j] = 0; U[i][j] = _A[i][j]; } } x[i][0] = 1; } inDL=DL.inverse(); c=inDL*b; H=inDL*U; int n=0; while(1){ tmp=x; x=c-H*x; T r = T(0); for(int i=0;i> A=_A; const int n = row, m = col; int r = 0; for(int i = 0; r < n && i < m; ++i) { int pivot = r; for(int j = r+1; j < n; ++j) if(fabs(A[j][i]) > fabs(A[pivot][i])) pivot = j; swap(A[pivot], A[r]); if(fabs(A[r][i]) < eps) continue; for (int k = m-1; k >= i; --k) A[r][k] /= A[r][i]; rep(j,r+1,n) rep(k,i,m) A[j][k] -= A[r][k] * A[j][i]; ++r; } return r; } }; template T npow(T x, ll n){ T ans(x.size_col()); while(n != 0){ if(n&1) ans = ans*x; x = x*x; n = n >> 1; } return ans; } int main(){ ll N,M,T; cin>>N>>M>>T; assert(N <= 100); MAT A(N,N), ans(N,1); REP(i,M) { int s,t; cin>>s>>t; A[s][t] = A[t][s] = 1; } ans[0][0] = 1; ans = npow(A,T)*ans; cout << ans[0][0] <