import sys sys.setrecursionlimit(5*10**5) input = sys.stdin.readline from collections import defaultdict, deque, Counter from heapq import heappop, heappush from bisect import bisect_left, bisect_right from math import gcd n,m,k = map(int,input().split()) graph = [[] for i in range(n+1)] for i in range(m): u,v = map(int,input().split()) graph[u-1].append(v-1) graph[v-1].append(u-1) mod = 998244353 mem = [-1]*(9**7) wa = 0 for i in range(n): wa += k*pow(9, i) pows = [pow(9, i) for i in range(9)] def f(cnt): if cnt//9 == wa: mem[cnt] = 1 return 1 if mem[cnt] != -1: return mem[cnt] res = 0 last = cnt % 9 for nxt in graph[last]: now = (cnt//pows[nxt+1]) % 9 if now == k: continue new = cnt//9 new += pows[nxt] new = new*9 + nxt res += f(new) res %= mod mem[cnt] = res return res ans = 0 for i in range(n): cnt = 0 cnt += pow(9, i+1) ans += f(cnt+i) ans %= mod print(ans)