#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long n;
long long dp[N];
long long a[N];
vector<long long> v;
long long solve(long long idx) {
  if (idx > n) return 0;
  if (idx == n) return 1;
  long long &ans = dp[idx];
  if (ans != -1) return ans;
  long long sz = v.size();
  long long op = 0;
  for (long long i = 0; i < sz; i++) {
    if (idx + v[i] > n) break;
    op += solve(idx + v[i]);
    op %= 998244353;
  }
  return ans = op;
}
void solve() {
  memset(dp, -1, sizeof dp);
  long long k;
  cin >> n >> k;
  for (long long i = 0; i < k; i++) {
    long long l, r;
    cin >> l >> r;
    a[l]++;
    a[r + 1]--;
  }
  for (long long i = 1; i < N; i++) {
    a[i] += a[i - 1];
  }
  for (long long i = 1; i < N; i++) {
    if (a[i]) v.push_back(i);
  }
  long long ans = solve(1);
  cout << ans;
}
int32_t main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  while (t--) solve();
}
