#include using namespace std; const int mod = 998244353; template class ModInt { int x; public: ModInt() : x(0) {} ModInt(long long int y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {} ModInt &operator+=(const ModInt& p) { if ((x += p.x) >= mod) { x -= mod; } return *this; } ModInt &operator-=(const ModInt& p) { if ((x += mod - p.x) >= mod) { x -= mod; } return *this; } ModInt &operator*=(const ModInt& p) { x = (int) (1LL * x * p.x % mod); return *this; } ModInt &operator/=(const ModInt& p) { *this *= p.Inverse(); return *this; } ModInt operator-() const { return ModInt(-x); } ModInt operator+(const ModInt& p) { return ModInt(*this) += p; } ModInt operator-(const ModInt& p) { return ModInt(*this) -= p; } ModInt operator*(const ModInt& p) { return ModInt(*this) *= p; } ModInt operator/(const ModInt& p) { return ModInt(*this) /= p; } bool operator==(const ModInt& p) { return x == p.x; } bool operator!=(const ModInt& p) { return x!= p.x; } ModInt Inverse() const { int a = x, m = mod, u = 1, v = 0, t; while (m > 0) { t = a / m; swap(a -= t * m, m); swap(u -= t * v, v); } return ModInt(u); } friend ostream &operator<<(ostream &os, const ModInt& p) { return os << p.x; } }; using Mint = ModInt; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, q; cin >> n >> q; vector a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } vector dp(n + 1), new_dp(n + 1); dp[0] = a[0] - 1; dp[1] = 1; for (int i = 1; i < n; ++i) { new_dp[0] = dp[0] * (a[i] - 1); for (int j = 1; j <= n; ++j) { new_dp[j] = dp[j - 1] + dp[j] * (a[i] - 1); } swap(dp, new_dp); } for (int i = 0; i < q; ++i) { int b; cin >> b; cout << dp[b] << '\n'; } return 0; }