#include <bits/stdc++.h>
using namespace std;
long long p[100];
map<long long, long long> m;
map<vector<long long>, long long> mp;
vector<long long> v, vp, vv, vk;
long long ans = 0;
void solve(int s, long long n) {
  if (n < 0) return;
  if (n == 0) {
    vp = vv;
    sort(vp.begin(), vp.end());
    if (mp[vp] == 0) {
      int cnt = 0;
      if (vv.size() > 1)
        for (int i = 1; i < vv.size(); i++) {
          if (vv[i] == vv[i - 1])
            cnt++;
          else {
            if (cnt > 1) vk.push_back(cnt);
            cnt = 0;
          }
        }
      if (vv[0] == vv[vv.size() - 1]) {
        ans++;
        ans %= 998244353;
      } else {
        ans += p[vv.size()];
        ans %= 998244353;
      }
      for (int i = 0; i < vk.size(); i++) ans %= vk[i];
      ans %= 998244353;
      mp[vp] = 1;
    }
    return;
  }
  for (int i = s; i < v.size(); i++) {
    vv.push_back(v[i]);
    solve(i, n - v[i]);
    vv.pop_back();
  }
}
int main() {
  long long a, b, t, n, i, j, k, l, mn = 0, mx = 0;
  p[0] = 1;
  for (int i = 1; i <= 22; i++) p[i] = p[i - 1] * i;
  scanf("%lld%lld", &n, &k);
  for (int i = 0; i < k; i++) {
    cin >> a;
    if (m[a] == 0) v.push_back(a), m[a] = 1;
    cin >> a;
    if (m[a] == 0) v.push_back(a), m[a] = 1;
  }
  solve(0, n - 1);
  cout << ans;
}
