#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; typedef unsigned int ui; const ll mod = 1000000007; const ll INF = (ll)1000000007 * 1000000007; typedef pair P; #define stop char nyaa;cin>>nyaa; #define rep(i,n) for(int i=0;i=0;i--) #define Rep(i,sta,n) for(int i=sta;i=sta;i--) #define rep1(i,n) for(int i=1;i<=n;i++) #define per1(i,n) for(int i=n;i>=1;i--) #define Rep1(i,sta,n) for(int i=sta;i<=n;i++) typedef long double ld; const ld eps = 1e-8; const ld pi = acos(-1.0); typedef pair LP; int dx[4]={1,-1,0,0}; int dy[4]={0,0,1,-1}; templatebool chmax(T &a, const T &b) {if(abool chmin(T &a, const T &b) {if(b struct Matrix{ vector> val; Matrix(){} Matrix(int n,int m,T x=0):val(n,vector(m,x)){} Matrix(vector> a):val(a){} size_t size() const {return val.size();} inline vector& operator [] (int i) {return val[i];} Matrix &operator=(const vector> &A) { int n=A.size(),m=A[0].size(); val=A; return *this; } Matrix &operator+=(const Matrix &A) { for (int i=0;i &operator+=(const vector> &A) { return *this += Matrix(A); } Matrix &operator-=(const Matrix &A) { for (int i=0;i &operator-=(const vector> &A) { return *this -= Matrix(A); } Matrix &operator*=(const Matrix &A) { Matrix R(val.size(),A.val[0].size()); for (int i = 0; i < val.size(); ++i) for (int j = 0; j < A.val[0].size(); ++j) for (int k = 0; k < A.size(); ++k) R[i][j] = (R[i][j] | (val[i][k] & A.val[k][j])); for (int i=0;i &operator*=(const vector> &A) { return *this *= Matrix(A); } Matrix operator+(const Matrix &p) const { return Matrix(*this) += p; } Matrix operator-(const Matrix &p) const { return Matrix(*this) -= p; } Matrix operator*(const Matrix &p) const { return Matrix(*this) *= p; } bool operator==(const Matrix &p) const { return val == p.val; } bool operator!=(const Matrix &p) const { return val != p.val; } Matrix pow(long long n) { Matrix A=*this; Matrix R(A.size(), A.size()); for (int i = 0; i < A.size(); ++i) R[i][i] = 1; while (n > 0) { if (n & 1) R = R * A; A = A * A; n >>= 1; } return R; } }; int n,m;ll t; void solve(){ cin >> n >> m >> t; Matrix A(n,n),s(n,1);s[0][0]=1; rep(i,m){ int a,b;cin >> a >> b; A[b][a]=1; } Matrix ans=A.pow(t)*s; int x=0; rep(i,n) if(ans[i][0]==1)x++; cout << x << endl; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(50); solve(); }