#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k;
  cin >> n >> k;
  int g = k;
  set<int> st;
  vector<int> vc;
  while (g--) {
    int a, b;
    cin >> a >> b;
    if (st.find(a) == st.end()) {
      st.insert(a);
      vc.push_back(a);
    }
    if (st.find(b) == st.end()) {
      st.insert(b);
      vc.push_back(b);
    }
  }
  long long int dp[n + 1];
  for (int i = 0; i <= n; i++) dp[i] = 0;
  dp[n] = 0;
  for (int i = n - 1; i >= 1; i--) {
    if (st.find(n - i) != st.end()) dp[i] = (dp[i] + 1) % 998244353;
    for (int j = 0; j < vc.size(); j++) {
      if (i + vc[j] < n) dp[i] = (dp[i] + dp[i + vc[j]]) % 998244353;
    }
  }
  cout << dp[1] << endl;
  return 0;
}
