n,k=map(int,input().split())
a=[[int(i) for i in input().split()] for _ in range(k)]
s=set()
for x in a:
     s.add(x[0])
     s.add(x[1])
s=list(s)

count = [1]+[0]*n
for x in range(n + 1):
     for c in s:
          if x-c>=0:
               count[x]+=count[x-c]
print(count[-2]%998244353)