n, k = map(int, input().split())
a = list(set(sum([list(map(int, input().split())) for i in range(k)], [])))

def dfs(i):
  cnt = 0
  if i > n:
    return 0
  elif i == n:
    return 1
  for x in a:
    cnt += dfs(i+x)
  return cnt

print(dfs(1) % 998244353)