#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k, l, r, g[200005] = {}, dp[200005] = {};
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> l >> r;
    g[l] += 1;
    g[r + 1] -= 1;
  }
  for (int i = 2; i <= n; i++) {
    g[i] += g[i - 1];
  }
  dp[1] = 1;
  for (int i = 1; i < n; i++) {
    for (int j = 1; j <= n - i; j++) {
      if (g[j] >= 1) {
        dp[i + j] += dp[i];
      }
      dp[i + j] %= 998244353;
    }
  }
  cout << dp[n] << endl;
  return (0);
}
