#include <bits/stdc++.h>
using namespace std;
set<int> s;
int n, k, c;
const long long mod = 998244353;
int walk_th(int x) {
  int cnt = 0;
  if (x == n) return 1;
  for (set<int>::iterator it = s.begin(); it != s.end(); it++)
    if ((x + *it) <= n) cnt += walk_th(x + *it);
  return cnt % mod;
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    cin >> c;
    s.insert(c);
    cin >> c;
    s.insert(c);
  }
  cout << walk_th(1);
  return 0;
}
