#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main(void) {
  ll N, K;
  cin >> N >> K;
  ll L, R;
  set<ll> S;
  for (ll i = 0; i < ll(K); i++) {
    cin >> L >> R;
    S.insert(L);
    S.insert(R);
  }
  ll ans = 0;
  vector<int> X(1, 1);
  while (X.size() > 0) {
    int num = X[X.size() - 1];
    X.pop_back();
    for (auto j : S) {
      if (num + j < N) {
        X.push_back(num + j);
      } else if (num + j == N) {
        ans++;
      } else {
      }
    }
  }
  cout << ans % 998244353 << endl;
  return 0;
}
