#include <bits/stdc++.h>
using namespace std;
uint64_t add(uint64_t a, uint64_t b) {
  uint64_t res = a + b;
  while (res >= 998244353) res -= 998244353;
  while (res < 0) res += 998244353;
  return res;
}
uint64_t countWays(vector<uint64_t>& s, uint64_t m, uint64_t N) {
  uint64_t count[N + 1];
  memset(count, 0, sizeof(count));
  count[0] = 1;
  for (int i = 1; i <= N; i++)
    for (int j = 0; j < m; j++)
      if (i >= s[j]) count[i] = add(count[i], count[i - s[j]]);
  return add(count[N], 0);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  uint64_t n, k, a, b;
  cin >> n >> k;
  set<uint64_t> s;
  for (uint64_t i = 0; i < k; i += 1) {
    cin >> a >> b;
    s.insert(a);
    s.insert(b);
  }
  vector<uint64_t> v(s.begin(), s.end());
  cout << countWays(v, v.size(), n - 1) << '\n';
  return 0;
}
