#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
long long countWays(long long arr[], long long m, long long N) {
  long long count[N + 1];
  memset(count, 0, sizeof(count));
  count[0] = 1;
  for (long long i = 1; i <= N; i++) {
    for (long long j = 0; j < m; j++) {
      if (i >= arr[j])
        count[i] = (count[i] % mod + count[i - arr[j]] % mod) % mod;
    }
  }
  return count[N];
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, k, a, b, i;
  set<long long> s;
  cin >> n >> k;
  while (k--) {
    cin >> a >> b;
    s.insert(a);
    s.insert(b);
  }
  long long m = s.size();
  long long arr[m];
  i = 0;
  for (auto it = s.begin(); it != s.end(); it++) {
    arr[i] = *it;
    i++;
  }
  long long N = n - 1;
  cout << countWays(arr, m, N);
  return 0;
}
