N,K=map(int,input().split())
x=998244353
S=[]
for i in range(K):
    l,r=map(int,input().split())
    S.append(l)
    S.append(r)
S=list(set(S))
dp=[0 for i in range(N)]
print(S)
for i in range(N):
    for j in range(len(S)):
        if(i-S[j]>0):
            dp[i]+=dp[i-S[j]]
            dp[i]=dp[i]%x
        elif(i-S[j]==0):
            dp[i]+=1
            dp[i]=dp[i]%x
print(dp)