N, K = map(int, input().split())
S = set()
ans = [0] * (N + 1)
i = 1

for _ in range(K):
    S = S | set(map(int, input().split()))

while True:
    for d in S:
        flg = False
        if i + d <= N:
            flg = True
            ans[i + d] += 1
    if flg == False:
        break

print(ans[N] % 998244353)