#include using namespace std; const long long MOD = 998244353; int main(){ int N, Q; cin >> N >> Q; vector A(N); for (int i = 0; i < N; i++){ cin >> A[i]; } vector> dp(N + 1, vector(N + 1, 0)); dp[0][0] = 1; for (int i = 0; i < N; i++){ for (int j = 0; j <= i; j++){ dp[i + 1][j] += dp[i][j] * (A[i] - 1); dp[i + 1][j] %= MOD; dp[i + 1][j + 1] += dp[i][j]; dp[i + 1][j + 1] %= MOD; } } for (int i = 0; i < Q; i++){ int B; cin >> B; cout << dp[N][B] << endl; } }