#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
struct custom_hash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM =
        chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};
void io() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin.tie(0);
}
long long helper(long long cell, vector<long long> &v, vector<long long> &dp,
                 long long n) {
  if (cell == n) return 1;
  if (dp[cell] != -1) return dp[cell];
  long long res = 0;
  for (long long i = 0; i < v.size(); i++) {
    if (cell + v[i] <= n)
      res = (res % 998244353 + helper(cell + v[i], v, dp, n) % 998244353) %
            998244353;
    else
      break;
  }
  dp[cell] = res;
  return res;
}
int32_t main() {
  long long n, k, p, q;
  cin >> n >> k;
  map<long long, long long> make_pair;
  for (long long i = 0; i < k; i++) {
    cin >> p >> q;
    make_pair[p]++;
    make_pair[q]++;
  }
  vector<long long> v;
  for (auto x : make_pair) v.push_back(x.first);
  sort(v.begin(), v.end());
  vector<long long> dp(n + 1, -1);
  cout << helper(1, v, dp, n) % 998244353 << "\n";
  return 0;
}
