#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 998244353, M = 2e5 + 10;
int n, k;
unordered_set<int> t;
ll dp[M], a[11], b[11];
int main() {
  scanf("%d%d", &n, &k);
  for (int i = 0; i < k; i++) scanf("%lld%lld", a + i, b + i);
  for (int i = 0; i < k; i++) t.insert(a[i]), t.insert(b[i]);
  dp[1] = 1;
  for (int i = 2; i <= n; i++) {
    for (auto &x : t) {
      if (i > x) dp[i] = (dp[i] % mod + dp[i - x] % mod) % mod;
    }
  }
  printf("%lld\n", dp[n] % mod);
  return 0;
}
