from numpy import *
N,K = map(int,input().split())
LR = [list(map(int,input().split())) for k in range(K)]
D = (N+2)*[0]
dp = (N+1)*[0]
dp[1] = 1
mod = 998244353

for L,R in LR:
  D[L]+=1
  D[R+1]-=1

D = cumsum(D)

for i in range(1,N+1):
  for j in range(1,i):
    if D[j]==1:
      dp[i] = (dp[i]+dp[i-j])%mod

print(dp)