#include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef int64_t ll; typedef std::pair Pii; typedef std::pair Pll; typedef std::pair Pdd; #define rip(i, n, _s) for (int i = (_s);i < (int)( n ); i++) #define all(_l) _l.begin(), _l.end() #define rall(_l) _l.rbegin(), _l.rend() #define MM << " " << template using MaxHeap = std::priority_queue; template using MinHeap = std::priority_queue, std::greater>; template inline bool chmax(T &_l, const T b) { if (_l < b) { _l = b; return true; } return false; } template inline bool chmin(T &_l, const T b) { if (_l > b) { _l = b; return true; } return false; } # ifdef LOCAL_DEBUG template void vdeb(const std::vector &bb) { for (unsigned int i = 0;i < bb.size();i++) { if (i == bb.size() - 1) std::cout << bb[i]; else std::cout << bb[i] << ' '; } std::cout << '\n'; } template void vdeb(const std::vector> &bb) { for (unsigned int i = 0;i < bb.size();i++) { std::cout << i << ' '; vdeb(bb[i]); } std::cout << '\n'; } # endif using namespace std; vector> product(const vector> &a, const vector> &b) { int n = a.size(); vector> ret(n, vector(n)); rip(i,n,0) rip(j,n,0) { rip(k,n,0) ret[i][j] = ret[i][j] | (a[i][k]&b[k][j]); } return ret; } int main() { int n, m; cin >> n >> m; ll t; cin >> t; vector> da(n, vector(n)); rip(i,m,0) { int a, b; cin >> a >> b; da[a][b] = true; } vector> aft(n, vector(n)); rip(i,n,0) aft[i][i] = true; while(t) { if(t&1) aft = product(aft, da); da = product(da, da); t >>= 1; } int ans = 0; rip(i,n,0) ans += aft[0][i]; cout << ans << endl; }