#include <bits/stdc++.h>
using namespace std;
vector<int> lr;
int n, k, cnt, lr_size;
void reach(int a) {
  for (int i = 0; i < lr_size; i++) {
    if (a + lr[i] == n) {
      cnt++;
    } else if (n < a + lr[i]) {
      return;
    } else {
      reach(a + lr[i]);
    }
  }
  if (998244353 < cnt) {
    cnt = cnt / 998244353;
  }
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int l, r;
    cin >> l >> r;
    lr.push_back(l);
    lr.push_back(r);
  }
  sort(lr.begin(), lr.end());
  lr.erase(unique(lr.begin(), lr.end()), lr.end());
  lr_size = lr.size();
  reach(1);
  cout << cnt << endl;
  return 0;
}
