from typing import List M = List[List[int]] class MatPow: __slots__ = ("_n", "_mod", "_base", "_cacheLevel", "_useCache", "_cache") def __init__(self, base: M, mod=1000000007, cacheLevel=4): n = len(base) b = [0] * n * n for i in range(n): for j in range(n): b[i * n + j] = base[i][j] useCache = cacheLevel >= 2 self._n = n self._mod = mod self._base = b self._cacheLevel = cacheLevel self._useCache = useCache if useCache: self._cache = [[] for _ in range(cacheLevel - 1)] def pow(self, exp: int) -> M: if not self._useCache: return self._powWithOutCache(exp) if len(self._cache[0]) == 0: self._cache[0].append(self._base) for i in range(1, self._cacheLevel - 1): self._cache[i].append(self._mul(self._cache[i - 1][0], self._base)) e = self._eye(self._n) div = 0 while exp: if div == len(self._cache[0]): self._cache[0].append( self._mul(self._cache[self._cacheLevel - 2][div - 1], self._cache[0][div - 1]) ) for i in range(1, self._cacheLevel - 1): self._cache[i].append(self._mul(self._cache[i - 1][div], self._cache[0][div])) mod = exp % self._cacheLevel if mod: e = self._mul(e, self._cache[mod - 1][div]) exp //= self._cacheLevel div += 1 return self._to2D(e) def _mul(self, mat1: List[int], mat2: List[int]) -> List[int]: n = self._n res = [0] * n * n for i in range(n): for k in range(n): for j in range(n): res[i * n + j] = ( res[i * n + j] + mat1[i * n + k] * mat2[k * n + j] ) % self._mod return res def _powWithOutCache(self, exp: int) -> M: e = self._eye(self._n) b = self._base[:] while exp: if exp & 1: e = self._mul(e, b) exp >>= 1 b = self._mul(b, b) return self._to2D(e) def _eye(self, n: int) -> List[int]: res = [0] * n * n for i in range(n): res[i * n + i] = 1 return res def _to2D(self, mat: List[int]) -> M: n = self._n return [mat[i * n : (i + 1) * n] for i in range(n)] def __pow__(self, exp: int) -> M: return self.pow(exp) n, m, k = map(int, input().split()) adjMatrix = [[0] * n for _ in range(n)] for _ in range(m): u, v = map(int, input().split()) adjMatrix[u][v] = 1 adjMatrix[v][u] = 1 P = MatPow(adjMatrix, 998244353, cacheLevel=4) res = P.pow(k)[0][0] print(res)