#include <bits/stdc++.h>
using namespace std;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
vector<int> g[N];
int a[N];
int md = 998244353;
int dp[10000000];
int solve(int i, int n, vector<int> a, int ans = 0) {
  if (i > n) return 0;
  if (i == n) return 1;
  if (dp[i] != -1) return dp[i];
  for (auto it : a) {
    ans += solve(i + it, n, a) % md;
  }
  return dp[i] = ans % md;
}
int main() {
  ios_base::sync_with_stdio(0);
  long long int t, i, j, k, p, q, r, x, y, u, v, n, m;
  cin >> n >> k;
  set<int> s;
  memset(dp, -1, sizeof dp);
  for (i = 0; i < k; i++) {
    cin >> u >> v;
    s.insert(u);
    s.insert(v);
  }
  vector<int> a;
  for (auto it : s) a.push_back(it);
  cout << solve(1, n, a);
  cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " secs" << endl;
}
