#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vpi = vector<pii>;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll mod = 998244353;
  ll n, k;
  cin >> n >> k;
  set<ll> st;
  for (ll i = 0; i < k; i++) {
    ll x, y;
    cin >> x >> y;
    st.insert(x);
    st.insert(y);
  }
  vector<ll> a;
  for (ll x : st) a.push_back(x);
  sort(a.begin(), a.end());
  vector<ll> res(n, 0);
  res[0] = 1;
  for (ll j = 1; j < n; j++) {
    for (ll x : st) {
      if (j - x >= 0) res[j] = (res[j] + res[j - x]) % mod;
    }
  }
  cout << res[n - 1] << "\n";
  return 0;
}
