#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
const long long mod = 998244353;
void inputoutput() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
}
vector<int> adj[100500];
vector<bool> vis(100500);
vector<int> d(100500);
queue<int> q;
void bfs(int v) {
  q.push(v);
  vis[v] = true;
  while (!q.empty()) {
    int x = q.front();
    q.pop();
    for (auto u : adj[x]) {
      if (!vis[u]) {
        vis[u] = true;
        q.push(u);
        d[u] = d[v] + 1;
      }
    }
  }
}
void dfs(int v) {
  vis[v] = true;
  for (auto u : adj[v]) {
    if (!vis[u]) dfs(u);
  }
}
void solve() {
  long long int n, k;
  cin >> n >> k;
  vector<long long int> ar;
  map<long long int, long long int> mp;
  for (long long int i = 0; i < k; ++i) {
    long long int a, b;
    cin >> a >> b;
    if (mp.find(a) == mp.end()) {
      ar.push_back(a);
      mp[a]++;
    }
    if (mp.find(b) == mp.end()) {
      ar.push_back(b);
      mp[b]++;
    }
  }
  long long int dp[n];
  dp[n - 1] = 1;
  for (long long int i = n - 2; i >= 0; --i) {
    dp[i] = 0;
    for (long long int j = 0; j < ar.size(); ++j) {
      if (ar[j] + i < n) {
        dp[i] = (dp[i] % mod + dp[i + ar[j]] % mod + mod) % mod;
      }
    }
  }
  cout << (dp[0] + mod) % mod;
  cout << "\n";
}
int32_t main() {
  inputoutput();
  solve();
  return 0;
}
