#include <bits/stdc++.h>
using namespace std;
long long int countWays(vector<long long int> arr, long long int m,
                        long long int N) {
  long long int count[N + 2];
  memset(count, 0, sizeof(count));
  count[0] = 1;
  for (long long int i = 1; i <= N; i++) {
    for (long long int j = 0; j < m; j++) {
      if (i >= arr[j]) {
        count[i] =
            (count[i] % 998244353 + count[i - arr[j]] % 998244353) % 998244353;
      }
    }
  }
  return count[N] % 998244353;
}
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int x, y, i;
  set<long long int> st;
  for (i = 0; i < k; i++) {
    cin >> x >> y;
    st.insert(x);
    st.insert(y);
  }
  vector<long long int> arr;
  for (auto it : st) {
    arr.push_back(it);
  }
  long long int m = arr.size();
  long long int res = countWays(arr, m, n - 1) % 998244353;
  cout << res << endl;
  return 0;
}
