#include using namespace std; typedef long long int ll; typedef pair P; typedef vector VI; typedef vector VVI; const ll MOD = 998244353; const ll INF = 4611686018427387903; #define REP(i, n) for (int i = 0; i < n; i++) #define ALL(v) v.begin(), v.end() int main(){ int n, q; cin >> n >> q; VI a(n); REP(i,n) cin >> a[i]; VVI dp(n+1,VI(n+1,0)); dp[0][0]=1; REP(i,n){ REP(j,i+1){ dp[i+1][j+1]+=dp[i][j]; dp[i+1][j]+=dp[i][j]*(a[i]-1); dp[i+1][j]%=MOD; } dp[i+1][i+1]%=MOD; } VI b(q); REP(i,q) cin >> b[i]; REP(i,q){ cout << dp[n][b[i]] << endl; } return 0; }