output_description: Print the number of ways for Tak to go from Cell 1 to Cell N, modulo
  998244353.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N K
      L_1 R_1
      L_2 R_2
      :
      L_K R_K
attempt: N, K = map(int, input().split(" "))
  a = []
  d = []
  e = []
  for k in range(K):
      l, r = map(int, input().split(" "))
      d.append(l)
      e.append(r)
  d.sort()
  e.sort()
  for k in range(K):
      a += list(range(d[k], e[k] + 1))
  a.sort()
  b = [0 for i in range(a[-1] - 1)]
  b.append(1)
  for i in range(N - 1 - a[0]):
      b.append(0)
      for j in a:
          b[-1] += b[-j - 1]
  for i in range(a[0]):
      b.append(0)
  for j in a:
      b[-1] += b[-j - 1]
  print(b[-1] % 998244353)
  
problem_description: Statement
  
  There are N cells arranged in a row, numbered 1, 2, \ldots, N from left to
  right.
  
  Tak lives in these cells and is currently on Cell 1. He is trying to reach
  Cell N by using the procedure described below.
  
  You are given an integer K that is less than or equal to 10, and K non-
  intersecting segments [L_1, R_1], [L_2, R_2], \ldots, [L_K, R_K]. Let S be the
  union of these K segments. Here, the segment [l, r] denotes the set consisting
  of all integers i that satisfy l \leq i \leq r.
  
    * When you are on Cell i, pick an integer d from S and move to Cell i + d. You cannot move out of the cells.
  
  To help Tak, find the number of ways to go to Cell N, modulo 998244353.
samples: [{"input": "5 2\n    1 1\n    3 4", "output": "4\n    \n\nThe set S is the union of the segment [1, 1] and the segment [3, 4], therefore\nS = \\\\{ 1, 3, 4 \\\\} holds.\n\nThere are 4 possible ways to get to Cell 5:\n\n  * 1 \\to 2 \\to 3 \\to 4 \\to 5,\n  * 1 \\to 2 \\to 5,\n  * 1 \\to 4 \\to 5 and\n  * 1 \\to 5.\n\n* * *"}, {"input": "5 2\n    3 3\n    5 5", "output": "0\n    \n\nBecause S = \\\\{ 3, 5 \\\\} holds, you cannot reach to Cell 5. Print 0.\n\n* * *"}, {"input": "5 1\n    1 2", "output": "5\n    \n\n* * *"}, {"input": "60 3\n    5 8\n    1 3\n    10 15", "output": "221823067\n    \n\nNote that you have to print the answer modulo 998244353."}]