n,k = map(int, input().split(" "))
d_list = []
for i in range(k):
  a,b = map(int, input().split(" "))
  d_list.extend(range(a,b+1))


dp = [0 for s in range(n)]
dp[0] = 1
for i in range(n-1):
  for j in range(0,i+1):
    if (i+1-j) in d_list:
      dp[i+1] += dp[j]%998244353
      dp[i+1] = dp[i+1]%998244353
   
print(d_list)