#define MOD_TYPE 2 #include using namespace std; #include //#include //#include using namespace atcoder; #if 0 #include #include using Int = boost::multiprecision::cpp_int; using lld = boost::multiprecision::cpp_dec_float_100; #endif #if 0 #include #include #include #include using namespace __gnu_pbds; using namespace __gnu_cxx; template using extset = tree, rb_tree_tag, tree_order_statistics_node_update>; #endif #if 1 #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #endif #pragma region Macros using ll = long long int; using ld = long double; using pii = pair; using pll = pair; using pld = pair; template using smaller_queue = priority_queue, greater>; #if MOD_TYPE == 1 constexpr ll MOD = ll(1e9 + 7); #else #if MOD_TYPE == 2 constexpr ll MOD = 998244353; #else constexpr ll MOD = 1000003; #endif #endif using mint = static_modint; constexpr int INF = (int)1e9 + 10; constexpr ll LINF = (ll)4e18; constexpr double PI = acos(-1.0); constexpr double EPS = 1e-11; constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0}; constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0}; #define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i) #define rep(i, n) REP(i, 0, n) #define REPI(i, m, n) for (int i = m; i < (int)(n); ++i) #define repi(i, n) REPI(i, 0, n) #define YES(n) cout << ((n) ? "YES" : "NO") << "\n" #define Yes(n) cout << ((n) ? "Yes" : "No") << "\n" #define possible(n) cout << ((n) ? "possible" : "impossible") << "\n" #define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n" #define all(v) v.begin(), v.end() #define NP(v) next_permutation(all(v)) #define dbg(x) cerr << #x << ":" << x << "\n"; #define UNIQUE(v) v.erase(unique(all(v)), v.end()) struct io_init { io_init() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << setprecision(30) << setiosflags(ios::fixed); }; } io_init; template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } inline ll CEIL(ll a, ll b) { return (a + b - 1) / b; } template inline void Fill(A (&array)[N], const T& val) { fill((T*)array, (T*)(array + N), val); } template vector compress(vector& v) { vector val = v; sort(all(val)), val.erase(unique(all(val)), val.end()); for (auto&& vi : v) vi = lower_bound(all(val), vi) - val.begin(); return val; } template constexpr istream& operator>>(istream& is, pair& p) noexcept { is >> p.first >> p.second; return is; } template constexpr ostream& operator<<(ostream& os, pair p) noexcept { os << p.first << " " << p.second; return os; } ostream& operator<<(ostream& os, mint m) { os << m.val(); return os; } ostream& operator<<(ostream& os, modint m) { os << m.val(); return os; } template constexpr istream& operator>>(istream& is, vector& v) noexcept { for (int i = 0; i < v.size(); i++) is >> v[i]; return is; } template constexpr ostream& operator<<(ostream& os, vector& v) noexcept { for (int i = 0; i < v.size(); i++) os << v[i] << (i + 1 == v.size() ? "" : " "); return os; } random_device seed_gen; mt19937_64 engine(seed_gen()); struct BiCoef { vector fact_, inv_, finv_; BiCoef(int n) noexcept : fact_(n, 1), inv_(n, 1), finv_(n, 1) { fact_.assign(n, 1), inv_.assign(n, 1), finv_.assign(n, 1); for (int i = 2; i < n; i++) { fact_[i] = fact_[i - 1] * i; inv_[i] = -inv_[MOD % i] * (MOD / i); finv_[i] = finv_[i - 1] * inv_[i]; } } mint C(ll n, ll k) const noexcept { if (n < k || n < 0 || k < 0) return 0; return fact_[n] * finv_[k] * finv_[n - k]; } mint P(ll n, ll k) const noexcept { return C(n, k) * fact_[k]; } mint H(ll n, ll k) const noexcept { return C(n + k - 1, k); } mint Ch1(ll n, ll k) const noexcept { if (n < 0 || k < 0) return 0; mint res = 0; for (int i = 0; i < n; i++) res += C(n, i) * mint(n - i).pow(k) * (i & 1 ? -1 : 1); return res; } mint fact(ll n) const noexcept { if (n < 0) return 0; return fact_[n]; } mint inv(ll n) const noexcept { if (n < 0) return 0; return inv_[n]; } mint finv(ll n) const noexcept { if (n < 0) return 0; return finv_[n]; } }; BiCoef bc(500010); #pragma endregion // ------------------------------- #pragma region Matrix // 参考・引用:https://qiita.com/gnbrganchan/items/47118d45b3af9d5ae9a4 using Type = mint; struct Matrix { // 行列A vector> A; // コンストラクタ:第1引数⇒行数、第2引数⇒列数、第3引数⇒初期値 Matrix() : A() {} Matrix(int h, int w) : A(vector>(h, vector(w))) {} Matrix(int h, int w, Type d) : A(vector>(h, vector(w, d))) {} Matrix(vector> A) : A(A) {} Matrix(initializer_list> A) : A(A.begin(), A.end()) {} // 添え字アクセス vector operator[](const int i) const { return A[i]; } vector& operator[](const int i) { return A[i]; } // 行数・列数 int r = A.size(); int c = (A.empty() ? 0 : A[0].size()); // 行列同士の演算 Matrix& operator+=(const Matrix& B) { assert(c == B.c && r == B.r); rep(i, r) rep(j, c) A[i][j] += B[i][j]; return *this; } Matrix& operator-=(const Matrix& B) { assert(c == B.c && r == B.r); rep(i, r) rep(j, c) A[i][j] -= B[i][j]; return *this; } Matrix& operator*=(const Matrix& B) { if (B.r == 1 and B.c == 1) { return (*this) *= B[0][0]; } else if (r == 1 and c == 1) { Type k = A[0][0]; (*this) = B; return (*this) *= k; } assert(c == B.r); Matrix m2(r, B.c, 0); rep(i, r) rep(k, c) rep(j, B.c) m2[i][j] += A[i][k] * B[k][j]; c = B.c; // rep(i, r) A[i].resize(c); rep(i, r) rep(j, c) A[i][j] = m2[i][j]; return *this; } Matrix operator+(const Matrix& B) const { return Matrix(*this) += B; } Matrix operator-(const Matrix& B) const { return Matrix(*this) -= B; } Matrix operator*(const Matrix& B) const { return Matrix(*this) *= B; } vector operator*(const vector& b) const { assert(c == b.size()); vector res(r); rep(i, r) rep(k, c) res[i] += A[i][k] * b[k]; return res; } bool operator==(const Matrix& B) { assert(c == B.c && r == B.r); bool flg = true; rep(i, r) rep(j, c) if (A[i][j] != B[i][j]) flg = false; return flg; } // 行列とスカラの演算 Matrix& operator+=(const Type& k) { rep(i, r) rep(j, c) A[i][j] += k; return *this; } Matrix& operator-=(const Type& k) { rep(i, r) rep(j, c) A[i][j] -= k; return *this; } Matrix& operator*=(const Type& k) { rep(i, r) rep(j, c) A[i][j] *= k; return *this; } Matrix& operator/=(const Type& k) { rep(i, r) rep(j, c) A[i][j] /= k; return *this; } Matrix operator+(const Type& k) const { return Matrix(*this) += k; } Matrix operator-(const Type& k) const { return Matrix(*this) -= k; } Matrix operator*(const Type& k) const { return Matrix(*this) *= k; } Matrix operator/(const Type& k) const { return Matrix(*this) /= k; } Matrix operator-() const { return Matrix(*this) *= -1; } // 回転(degの数だけ時計回りに90度回転) Matrix& rot(int deg) { Matrix m2(c, r); if (deg == 1 || deg == 3) { if (deg == 1) rep(i, r) rep(j, c) m2[j][r - i - 1] = A[i][j]; if (deg == 3) rep(i, r) rep(j, c) m2[c - j - 1][i] = A[i][j]; swap(c, r); // 列数と行数を入れ替える A.resize(r); rep(i, r) A[i].resize(c); //リサイズ } if (deg == 2) rep(i, r) rep(j, c) m2[r - i - 1][c - j - 1] = A[i][j]; rep(i, r) rep(j, c) A[i][j] = m2[i][j]; return *this; } // 転置 Matrix& tran() { Matrix m2(c, r); rep(i, r) rep(j, c) m2[j][i] = A[i][j]; (*this) = m2; return *this; } // 単位行列 static Matrix E(int n) { Matrix res(n, n); rep(i, n) rep(j, n) res[i][j] = i == j; return res; } // 累乗 Matrix pow(ll n) { assert(n >= 0); Matrix res = E(r); Matrix P = (*this); while (n > 0) { if (n & 1) res *= P; P *= P; n >>= 1; } return res; } }; // 出力 ostream& operator<<(ostream& os, Matrix A) noexcept { rep(i, A.r) { if (i > 0) cout << "\n"; rep(j, A.c) { cout << A[i][j] << (j + 1 == A.c ? "" : " "); } } return os; } #pragma endregion void solve() { int n, m; ll t; cin >> n >> m >> t; Matrix A(n, n); rep(i, m) { int a, b; cin >> a >> b; A[a][b] = A[b][a] = 1; } vector b(n, 0); b[0] = 1; b = A.pow(t) * b; cout << b[0] << "\n"; } int main() { solve(); }