N, K = list(map(int, input().split()))
L = [list(map(int, input().split())) for i in range(K)]
LL=[]
for l in L:
    LL += l
S = set(LL)

c=['.' for i in range(N-1)]
c.append("g")
count=0

def dfs(x):
    global count
    if not (x < N):  #探索範囲外になった場合はreturn
        return
    if c[x] == "g":  # ゴールを見つけたらカウント
        count+=1

    for s in S:
        dfs(x + s)

dfs(0)
print(count % 998244353)