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())
  lrl = []
  for _ in range(k):
      lrl.append(list(map(int,input().split())))
  
  N = 2 * n
  # N: 処理する区間の長さ
  
  data0 = [0]*(N+1)
  data1 = [0]*(N+1)
  
  mod = 998244353
  # 区間[l, r)に x を加算
  def _add(data, k, x):
      while k <= N:
          x %= mod
          data[k] += x
          data[k] %= mod
          k += k & -k
  def add(l, r, x):
      _add(data0, l, -x*(l-1)%mod)
      _add(data0, r, x*(r-1)%mod)
      _add(data1, l, x)
      _add(data1, r, -x)
  
  # 区間[l, r)の和を求める
  def _get(data, k):
      s = 0
      while k:
          s += data[k]
          s %= mod
          k -= k & -k
      return s
  def query(l, r):
      return _get(data1, r-1) * (r-1) + _get(data0, r-1) - _get(data1, l-1) * (l-1) - _get(data0, l-1)
  
  add(1, 2, 1)
  for i in range(n):
      now = query(i+1, i+2) 
      for l, r in lrl:
          add(l+i+1, r+i+2, now % mod)
  
  print(query(n, n+1) % mod)
  
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."}]