#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 10;
const int mod = 998244353;
int vis[maxn];
long long int dp[maxn];
int c[maxn];
int main() {
  int N, K;
  while (~scanf("%d%d", &N, &K)) {
    memset(vis, 0, sizeof(vis));
    memset(dp, 0, sizeof(dp));
    int l, r;
    int num = 0;
    for (int i = 0; i < K; i++) {
      scanf("%d%d", &l, &r);
      if (!vis[l]) c[num++] = l, vis[l] = 1;
      if (!vis[r]) c[num++] = r, vis[r] = 1;
    }
    dp[0] = 1LL;
    for (int i = 0; i <= N - 1; i++) {
      for (int j = 0; j < num; j++) {
        if (i >= c[j]) dp[i] = (dp[i] + dp[i - c[j]]) % mod;
      }
    }
    cout << dp[N - 1] << endl;
  }
  return 0;
}
