#include #define be(v) (v).begin(),(v).end() #define pb(q) push_back(q) #define rep(i, n) for(int i=0;i struct Matrix { vector > val; // 縦, 横, 初期値 Matrix(int n = 1, int m = 1, T v = 0) : val(n, vector(m, v)) {} void init(int n, int m, T v = 0) {val.assign(n, vector(m, v));} Matrix& operator = (const Matrix &A) { val = A.val; return *this; } size_t size() const {return val.size();} vector& operator [] (int i) {return val[i];} const vector& operator [] (int i) const {return val[i];} friend ostream& operator << (ostream& s, const Matrix& M) { s << endl; for (int i = 0; i < (int)M.size(); ++i) s << M[i] << endl; return s; } }; template Matrix operator * (const Matrix &A, const Matrix &B) { Matrix R(A.size(), B[0].size()); for (int i = 0; i < A.size(); ++i) for (int j = 0; j < B[0].size(); ++j) for (int k = 0; k < B.size(); ++k) R[i][j] += A[i][k] * B[k][j]; return R; } template Matrix pow(const Matrix &A, long long n) { Matrix R(A.size(), A.size()); auto B = A; for (int i = 0; i < A.size(); ++i) R[i][i] = 1; while (n > 0) { if (n & 1) R = R * B; B = B * B; n >>= 1; } return R; } template vector operator * (const Matrix &A, const vector &B) { vector v(A.size()); for (int i = 0; i < A.size(); ++i) for (int k = 0; k < B.size(); ++k) v[i] += A[i][k] * B[k]; return v; } template Matrix operator + (const Matrix &A, const Matrix &B) { Matrix R(A.size(), A[0].size()); for (int i = 0; i < A.size(); ++i) for (int j = 0; j < A[0].size(); ++j) R[i][j] = A[i][j] + B[i][j]; return R; } template Matrix operator - (const Matrix &A, const Matrix &B) { Matrix R(A.size(), A[0].size()); for (int i = 0; i < A.size(); ++i) for (int j = 0; j < A[0].size(); ++j) R[i][j] = A[i][j] - B[i][j]; return R; } int main() { cin.tie(0); cout.tie(0); ios::sync_with_stdio(false); ll n, m, t; cin >> n >> m >> t; Matrix mat(n, n, 0); int a, b; for(int i=0;i> a >> b; mat[b][a] = 1; } mat = pow(mat, t); int ans = 0; for(int i=0;i