#include <bits/stdc++.h>
using namespace std;
const int m = 998244353;
int findWays(int start, int n, set<int> &s, vector<long long> &dp) {
  if (start > n) return 0;
  if (start == n) return 1;
  if (dp[start] != -1) return dp[start];
  long long curr_jumps = 0;
  for (auto jump : s) {
    curr_jumps = ((curr_jumps % m + findWays(start + jump, n, s, dp) % m) % m);
  }
  dp[start] = curr_jumps % m;
  return dp[start] % m;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, d;
  cin >> n >> d;
  set<int> jumps;
  while (d--) {
    int x, y;
    cin >> x >> y;
    jumps.insert(x);
    jumps.insert(y);
  }
  vector<long long> dp(n, -1);
  findWays(1, n, jumps, dp);
  cout << dp[1] % m << '\n';
  return 0;
}
