#include <bits/stdc++.h>
using namespace std;
signed main() {
  long long n, k;
  cin >> n >> k;
  set<long long> s;
  for (long long i = 0; i < k; ++i) {
    long long a, b;
    cin >> a >> b;
    s.insert(a);
    s.insert(b);
  }
  vector<long long> v;
  for (set<long long>::iterator it = s.begin(); it != s.end(); ++it)
    v.push_back(*it);
  long long f[n + 1];
  f[1] = 1;
  for (long long i = 2; i <= n; ++i) {
    f[i] = 0;
    for (long long j = 0; j < v.size(); ++j)
      if (v[j] < i)
        f[i] = (f[i] + f[i - v[j]]) % 998244353;
      else
        break;
  }
  cout << f[n] << endl;
  return 0;
}
