#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000 + 7;
const long long LINF = INF * (long long)INF;
const int mod = 998244353;
const int MAX = 1 << 25;
int dp[21][1005];
int c[1005][1005];
int n, k;
int a[20];
int mult(int a, int b) { return a * (long long)b % mod; }
int add(int a, int b) { return a + b >= mod ? a + b - mod : a + b; }
void Add(int &a, int b) { a = add(a, b); }
int main() {
  int n, k;
  cin >> n >> k;
  for (int i = 0; i < k; i++) cin >> a[i];
  for (int i = 0; i <= n; i++) {
    c[i][0] = 1;
    for (int j = 1; j <= i; j++) {
      c[i][j] = add(c[i - 1][j], c[i - 1][j - 1]);
    }
  }
  dp[0][0] = 1;
  for (int i = 0; i < k; i++)
    for (int j = 0; j <= n; j++)
      for (int l = 0; l <= min(n - j, a[i]); l++)
        Add(dp[i + 1][j + l],
            mult(dp[i][j], mult(c[n - l][a[i] - l], c[n - j][l])));
  cout << dp[k][n];
}
