n,k = map(int,input().split())
s = []
for i in range(k):
    l,r = map(int,input().split())
    s.append(l)
    s.append(r)
suji = 998244353

_s = set(s)
pos=[]
 
def dfs(x):
    if x > n:
        return
    if x == n:
        pos.append(True)
    for i in _s:
        dfs(x+i)
        
dfs(1)
 
num = pos.count(True)
 
print(num%suji)
