#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 998244353;
long long dp[200010];
int main() {
  int n, k;
  cin >> n >> k;
  int l, r;
  map<int, int> mp;
  for (int i = 0; i < k; i++) {
    cin >> l >> r;
    mp[l]++;
    mp[r]++;
  }
  vector<int> vec;
  for (auto itr = mp.begin(); itr != mp.end(); itr++) {
    if (itr->second > 0) {
      vec.push_back(itr->first);
    }
  }
  sort(vec.begin(), vec.end());
  int s = vec.size();
  dp[1] = 1;
  for (int i = 2; i <= n + 1; i++) {
    for (int j = s - 1; j >= 0; j--) {
      if (i - vec[j] < 1) continue;
      dp[i] += dp[i - vec[j]];
    }
    dp[i] %= MOD;
  }
  cout << dp[n] << endl;
  return 0;
}
