#include <bits/stdc++.h>
using namespace std;
long long int mod = 998244353;
const int maxN = 1e6;
long long int dp[maxN];
long long int solve(vector<int> &steps, int n) {
  if (n <= 0) return 0;
  if (n == 1) return 1;
  if (dp[n] != -1) return dp[n];
  long long int ans = 0;
  for (int i : steps) {
    ans = (ans % mod + solve(steps, n - i) % mod) % mod;
  }
  return dp[n] = ans;
}
int main() {
  int n, k;
  cin >> n >> k;
  set<int> s;
  for (int i = 0; i <= n; i++) dp[i] = -1;
  for (int i = 0; i < k; i++) {
    int u, v;
    cin >> u >> v;
    s.insert(u);
    s.insert(v);
  }
  vector<int> step;
  for (auto i : s) step.push_back(i);
  long long int cnt = solve(step, n);
  cout << cnt;
  return 0;
}
