div = 998244353

N, K = map(int, input().split())
L = set()
for _ in range(K):
    L = L.union(set(list(map(int, input().split()))))

Lst = list(L)
Lst.reverse()
print(Lst)

def cntroot(remaining, cnt, Lst):
    for x in Lst:
        if (remaining - x) >  0:
            cnt = cntroot(remaining - x, cnt, Lst)
        elif (remaining - x) == 0:
            cnt += 1
        else:
            pass
    return cnt

print(cntroot(N - 1, 0, Lst) % div)