## https://yukicoder.me/problems/no/1750 MOD = 998244353 def prod_matrix(N, mat1, mat2): new_matrix = [[0] * N for _ in range(N)] for i in range(N): for j in range(N): for k in range(N): new_matrix[i][j] += (mat1[i][k] * mat2[k][j]) % MOD new_matrix[i][j] %= MOD return new_matrix def prod_vector(N, mat, vec): new_vector = [0] * N for i in range(N): for j in range(N): new_vector[i] += (mat[i][j] * vec[j]) % MOD new_vector[i] %= MOD return new_vector def main(): N, M, T = map(int, input().split()) st = [] for _ in range(M): s, t = map(int, input().split()) st.append((s, t)) base_matrix = [ [0] * N for _ in range(N) ] for s, t in st: base_matrix[s][t] = 1 base_matrix[t][s] = 1 vector = [0] * N vector[0] = 1 while T > 0: if T % 2 == 1: vector = prod_vector(N, base_matrix, vector) base_matrix = prod_matrix(N, base_matrix, base_matrix) T //= 2 print(vector[0]) if __name__ == "__main__": main()