#include <bits/stdc++.h>
using namespace std;
const int N = 1200005, P = 998244353;
using ll = long long;
ll qpow(ll a, ll b) {
  ll ret = 1;
  while (b) {
    if (b & 1) ret = ret * a % P;
    a = a * a % P;
    b >>= 1;
  }
  return ret;
}
int n, m, q, kk, cnt[N];
ll fac[N], ifac[N], ans[N];
inline ll C(int n, int m) { return fac[n] * ifac[m] % P * ifac[n - m] % P; }
ll a[N], b[N];
int rev[N];
void NTT(ll a[], int fl, int n) {
  for (int i = 0; i < n; i++)
    if (i < rev[i]) swap(a[i], a[rev[i]]);
  for (int s = 1; s < n; s <<= 1) {
    ll gn = qpow(3, (P - 1) / (s << 1));
    if (fl == -1) gn = qpow(gn, P - 2);
    for (int j = 0; j < n; j += s << 1) {
      ll g = 1;
      for (int k = 0; k < s; k++, g = g * gn % P) {
        ll x = a[j + k], y = a[j + s + k] * g % P;
        a[j + k] = (x + y) % P;
        a[j + s + k] = (x - y) % P;
      }
    }
  }
  if (fl == -1) {
    ll invn = qpow(n, P - 2);
    for (int i = 0; i < n; i++) a[i] = a[i] * invn % P;
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> kk;
  int t1;
  for (int i = 1; i <= n; i++) cin >> t1, ++cnt[t1];
  fac[0] = 1;
  for (int i = 1; i <= n; i++) fac[i] = i * fac[i - 1] % P;
  ifac[n] = qpow(fac[n], P - 2);
  for (int i = n; i > 0; --i) ifac[i - 1] = ifac[i] * i % P;
  for (int _ = 1; _ <= kk; _++) {
    cin >> t1;
    int ac = 0, bc = 0;
    for (int i = 1; i < t1; i++)
      if (cnt[i] > 1)
        bc += 2;
      else if (cnt[i])
        ++ac;
    memset(a, 0, sizeof(a));
    memset(b, 0, sizeof(b));
    for (int i = 0; i <= ac; i++) a[i] = C(ac, i) * qpow(2, i) % P;
    for (int i = 0; i <= bc; i++) b[i] = C(bc, i);
    int cc = ac + bc, l = 0, lim = 1;
    while (lim <= cc) ++l, lim <<= 1;
    for (int i = 1; i < lim; i++)
      rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (l - 1));
    NTT(a, 1, lim);
    NTT(b, 1, lim);
    for (int i = 0; i < lim; i++) a[i] = a[i] * b[i] % P;
    NTT(a, -1, lim);
    for (int i = 0; i <= cc; i++)
      ans[(i + 1 + t1) << 1] = (ans[(i + 1 + t1) << 1] + a[i]) % P;
  }
  cin >> q;
  for (int _ = 1; _ <= q; _++) cin >> t1, cout << (ans[t1] + P) % P << '\n';
  return 0;
}
