#include <bits/stdc++.h>
using namespace std;
long long int mod = 998244353;
long long int n;
long long int dp[100001];
long long int find(vector<long long int> v, long long int curr) {
  if (curr == n) return 1;
  if (curr > n) return 0;
  if (dp[curr] != -1) return dp[curr];
  long long int ans = 0;
  for (long long int j = 0; j < v.size(); j++) {
    if (curr + v[j] <= n) {
      ans = (ans + find(v, curr + v[j])) % mod;
    }
  }
  return dp[curr] = ans % mod;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int k, a, b;
  cin >> n >> k;
  memset(dp, -1, sizeof dp);
  set<long long int> s;
  for (long long int i = 0; i < k; i++) {
    cin >> a >> b;
    s.insert(a), s.insert(b);
  }
  vector<long long int> v;
  for (auto it = s.begin(); it != s.end(); it++) {
    a = (long long int)*it;
    v.push_back(a);
  }
  cout << find(v, 1);
  return 0;
}
