#include <bits/stdc++.h>
using namespace std;
int countWays(int arr[], int m, int N) {
  int 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 >= arr[j]) count[i] += count[i - arr[j]];
  return count[N];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long int i, N, t, j = 0, p, x, a = 0, b, l = 0, r = 0, y, k, c, sum = 0,
                         m = 0, d, z;
  cin >> N >> k;
  int arr[N];
  set<int> se;
  set<int>::iterator it;
  while (k--) {
    cin >> a >> b;
    se.insert(a);
    se.insert(b);
  }
  for (it = se.begin(); it != se.end(); it++) {
    arr[m++] = *it;
  }
  m = sizeof(arr) / sizeof(arr[0]);
  cout << countWays(arr, m, N - 1) % 998244353 << endl;
  return EXIT_SUCCESS;
}
