#include <bits/stdc++.h>
using namespace std;
const int MAXK = 10 + 2;
const int MO = 998244353;
int n, k;
int l[MAXK];
int len = 0;
unsigned long long ans = 0;
vector<int> rec;
void dfs(int sum) {
  if (sum == n) {
    if (1 == rec[0]) {
      ans = (ans + 1) % MO;
    }
    return;
  }
  if (sum > n) {
    return;
  }
  for (int i = 0; i < len; i++) {
    rec.push_back(sum + l[i]);
    dfs(sum + l[i]);
    rec.pop_back();
  }
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < k; i++) {
    int x;
    for (int j = 0; j < 2; j++) {
      cin >> x;
      int *p = find(l, l + len, x);
      if (p == l + len) {
        l[len] = x;
        len++;
      }
    }
  }
  dfs(0);
  cout << ans << "\n";
  return 0;
}
