#include <bits/stdc++.h>
using namespace std;
using ll = long long;
class DLeapingTak {
 public:
  int change(int amount, vector<int>& coins) {
    vector<int> dp(amount + 1, 0);
    dp[0] = 1;
    for (int i = 1; i <= amount; i++) {
      for (int j = 0; j < coins.size() && coins[j] <= i; j++) {
        dp[i] += dp[i - coins[j]];
        dp[i] %= 998244353;
      }
    }
    return dp[amount];
  }
  void solve(std::istream& cin, std::ostream& cout) {
    int n, k;
    cin >> n >> k;
    set<int> s;
    for (int i = 0; i < k; i++) {
      int a, b;
      cin >> a >> b;
      s.insert(a);
      s.insert(b);
    }
    vector<int> v;
    for (auto it : s) v.push_back(it);
    cout << change(n - 1, v);
  }
};
int main() {
  DLeapingTak solver;
  std::ios::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
