#include <bits/stdc++.h>
using namespace std;
const int MAXK = 10 + 2;
const int MO = 998244353;
int l[MAXK];
int len = 0;
stack<int> myStack;
unsigned long long dfs(int start, int target) {
  unsigned long long ans = 0;
  myStack.push(start);
  while (false == myStack.empty()) {
    int x = myStack.top();
    myStack.pop();
    for (int i = 0; i < len; i++) {
      int y = x + l[i];
      if (target == y) {
        ans = (ans + 1) % MO;
      } else if (target > y) {
        myStack.push(y);
      } else {
        break;
      }
    }
  }
  return ans;
}
int main() {
  int n, k;
  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++;
      }
    }
  }
  sort(l, l + len);
  unsigned long long ans = dfs(1, n);
  cout << ans << "\n";
  return 0;
}
