#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int MOD = 1000000007;
set<long long> uniq;
long long n, k;
int dfs(int root) {
  if (root > n) {
    return 0;
  } else if (root == n) {
    return 1;
  } else {
    long long sum = 0;
    for (auto item : uniq) {
      sum += dfs(root + item);
    }
    return sum;
  }
}
int main() {
  cin >> n >> k;
  for (long long i = 0; i < k; ++i) {
    long long l, r;
    cin >> l >> r;
    uniq.insert(l);
    uniq.insert(r);
  }
  long long rs = dfs(1);
  cout << rs % 998244353 << endl;
}
