# ABC179-D Leaping Tak
goalN, shugosuK = map(int, input().strip().split(' '))
# print(goalN, shugosuK)
shugo = []
wa = []
for i in range(shugosuK):
    shugo = list(map(int, input().strip().split(' ')))
    # print('shugo', shugo)
    wa = wa + shugo
    # print('wa', wa)
    # wa = set(wa)
# print(wa)
wa = list(set(wa))
# print(wa)
l = len(wa)

def dfs(pos, cnt):
    for i in range(l):
        newpos = pos + wa[i]
        if newpos == goalN:
            pos = newpos
            cnt += 1
            return cnt
        elif newpos > goalN:
            pos = newpos
            return cnt
        elif newpos < goalN:
            pos = newpos
            dfs(pos, cnt)

cnt = dfs(1, 0)
cnt = cnt % 998244353
print(cnt)