#include <bits/stdc++.h>
using namespace std;
const int64_t MOD = 998244353;
const int64_t INF = 1e18;
void io(string s = "file") {
  freopen((s + ".in").c_str(), "r", stdin);
  freopen((s + ".out").c_str(), "w", stdout);
}
int64_t n;
int64_t dp[200005];
int64_t ff[200005];
vector<int64_t> v;
int64_t f(int64_t cell) {
  if (cell > n) return 0;
  if (cell == n) return 1;
  int64_t &ans = dp[cell];
  if (ans != -1) return ans;
  ans = 0;
  for (int64_t i : v) {
    ans += f(cell + i);
    ans %= MOD;
  }
  return ans;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int64_t k;
  cin >> n >> k;
  memset(dp, -1, sizeof dp);
  for (int64_t i = 0; i < k; i++) {
    int64_t l, r;
    cin >> l >> r;
    ff[l]++;
    ff[r + 1]--;
  }
  for (int64_t i = 1; i <= 2e5; i++) {
    ff[i] += ff[i - 1];
    if (ff[i]) v.push_back(i);
  }
  cout << f(1);
}
