/* -*- coding: utf-8 -*- * * 2733.cc: No.2733 Just K-times TSP - yukicoder */ #include #include #include using namespace std; /* constant */ const int MAX_N = 6; const int MAX_K = 9; const int BITS = 531441; // = 9^6 const int MOD = 998244353; /* typedef */ typedef vector vi; /* global variables */ vi nbrs[MAX_N]; int dp[BITS][MAX_N], vs[MAX_N]; /* subroutines */ int v2b(int n, int k, int v[]) { int bits = 0; for (int i = n - 1; i >= 0; i--) bits = bits * (k + 1) + v[i]; return bits; } void b2v(int bits, int n, int k, int v[]) { for (int i = 0; i < n; i++, bits /= (k + 1)) v[i] = bits % (k + 1); } inline void addmod(int &a, int b) { a = (a + b) % MOD; } /* main */ int main() { int n, m, k; scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < m; i++) { int u, v; scanf("%d%d", &u, &v); u--, v--; nbrs[u].push_back(v); nbrs[v].push_back(u); } int ebits = 1; for (int i = 0; i < n; i++) ebits *= (k + 1); for (int i = 0; i < n; i++) { vs[i] = 1; dp[v2b(n, k, vs)][i] = 1; vs[i] = 0; } for (int bits = 0; bits < ebits; bits++) { b2v(bits, n, k, vs); for (int u = 0; u < n; u++) if (dp[bits][u]) { for (auto v: nbrs[u]) if (vs[v] < k) { vs[v]++; addmod(dp[v2b(n, k, vs)][v], dp[bits][u]); vs[v]--; } } } int sum = 0; for (int u = 0; u < n; u++) addmod(sum, dp[ebits - 1][u]); printf("%d\n", sum); return 0; }