#include <bits/stdc++.h>
using namespace std;
using namespace std;
set<long long> SSS;
long long N, K;
long long ans = 0;
void debugV(vector<long long>& deV) {
  for (long long i = 0; i < deV.size(); i++) {
    cout << "[" << i << "]= " << deV[i] << ",";
  }
  cout << endl;
}
void debugVV(vector<vector<long long> >& deV) {
  for (long long i = 0; i < deV.size(); i++) {
    cout << i << " ";
    for (long long j = 0; j < deV[i].size(); j++) {
      cout << "[" << j << "]= " << deV[i][j] << ",";
    }
    cout << endl;
  }
}
long long c = 0;
void dfs(long long now) {
  if (now == N) {
    ans++;
    return;
  }
  if (now > N) {
    return;
  }
  c++;
  for (auto sss : SSS) {
    if (c == 1) cout << "now SSS = " << now << " " << sss << endl;
    dfs(now + sss);
  }
}
signed main() {
  cin >> N >> K;
  vector<long long> LR(K * 2);
  for (long long i = 0; i < (long long)(K * 2); i++) {
    cin >> LR[i];
  }
  set<long long> S;
  for (long long i = 0; i < (long long)(K * 2); i++) {
    S.insert(LR[i]);
  }
  SSS = S;
  dfs(1);
  cout << ans % 998244353 << endl;
}
