#include <bits/stdc++.h>
using namespace std;
const int A = 119, B = 23, P = A << B | 1, R = 3;
const int g = 3;
const int LOGN = 20;
const int N = (1 << LOGN);
inline int mul(int a, int b) { return (a * 1ll * b) % 998244353; }
inline int norm(int a) {
  while (a >= 998244353) a -= 998244353;
  while (a < 0) a += 998244353;
  return a;
}
inline int binPow(int a, int k) {
  int ans = 1;
  while (k > 0) {
    if (k & 1) ans = mul(ans, a);
    a = mul(a, a);
    k >>= 1;
  }
  return ans;
}
inline int inv(int a) { return binPow(a, 998244353 - 2); }
vector<int> w[LOGN];
vector<int> iw[LOGN];
vector<int> rv[LOGN];
void precalc() {
  int wb = binPow(g, (998244353 - 1) / (1 << LOGN));
  for (int st = 0; st < LOGN; st++) {
    w[st].assign(1 << st, 1);
    iw[st].assign(1 << st, 1);
    int bw = binPow(wb, 1 << (LOGN - st - 1));
    int ibw = inv(bw);
    int cw = 1;
    int icw = 1;
    for (int k = 0; k < (1 << st); k++) {
      w[st][k] = cw;
      iw[st][k] = icw;
      cw = mul(cw, bw);
      icw = mul(icw, ibw);
    }
    rv[st].assign(1 << st, 0);
    if (st == 0) {
      rv[st][0] = 0;
      continue;
    }
    int h = (1 << (st - 1));
    for (int k = 0; k < (1 << st); k++)
      rv[st][k] = (rv[st - 1][k & (h - 1)] << 1) | (k >= h);
  }
}
inline void fft(int a[N], int n, int ln, bool inverse) {
  for (int i = 0; i < n; i++) {
    int ni = rv[ln][i];
    if (i < ni) swap(a[i], a[ni]);
  }
  for (int st = 0; (1 << st) < n; st++) {
    int len = (1 << st);
    for (int k = 0; k < n; k += (len << 1)) {
      for (int pos = k; pos < k + len; pos++) {
        int l = a[pos];
        int r = mul(a[pos + len], (inverse ? iw[st][pos - k] : w[st][pos - k]));
        a[pos] = norm(l + r);
        a[pos + len] = norm(l - r);
      }
    }
  }
  if (inverse) {
    int in = inv(n);
    for (int i = 0; i < n; i++) a[i] = mul(a[i], in);
  }
}
int aa[N], bb[N];
int multiply(vector<long long> &a, vector<long long> &b) {
  int n = 1, ln = 0;
  while (n < ((int)(a).size()) + ((int)(b).size())) n <<= 1, ++ln;
  for (int i = 0; i < n; i++) aa[i] = (i < a.size() ? a[i] : 0);
  for (int i = 0; i < n; i++) bb[i] = (i < b.size() ? b[i] : 0);
  fft(aa, n, ln, false);
  fft(bb, n, ln, false);
  for (int i = 0; i < n; i++) aa[i] = mul(aa[i], bb[i]);
  fft(aa, n, ln, true);
  return n;
}
const int mod = 998244353;
int a[N], b[5];
int Q[N];
int ret[N];
int vis[N];
int fac[N], invFac[N];
int C(int n, int r) {
  if (n < r || n < 0 || r < 0) {
    return 0;
  }
  return mul(fac[n], mul(invFac[r], invFac[n - r]));
}
vector<long long> newtonExp(int a, int b, int p) {
  vector<long long> res(p + 1);
  for (int i = 0; i <= p; i++)
    res[i] = mul(C(p, i), mul(binPow(a, i), binPow(b, p - i)));
  return res;
}
int p2[N];
void solve() {
  int n, k;
  precalc();
  fac[0] = 1;
  invFac[0] = 1;
  p2[0] = 1;
  for (int i = 1; i < N; ++i) {
    fac[i] = mul(fac[i - 1], i);
    invFac[i] = binPow(fac[i], mod - 2);
    p2[i] = mul(p2[i - 1], 2);
  }
  scanf("%d %d ", &n, &k);
  map<int, int> cnt;
  for (int i = 0; i < n; ++i) {
    scanf("%d ", &a[i]);
    ++cnt[a[i]];
  }
  for (int i = 0; i < k; ++i) {
    scanf("%d ", &b[i]);
  }
  sort(a, a + n);
  sort(b, b + k);
  int q;
  scanf("%d ", &q);
  for (int i = 0; i < q; ++i) {
    scanf("%d ", &Q[i]);
    Q[i] /= 2;
  }
  for (int x = 0; x < k; ++x) {
    int un = 0, non = 0, pos = 0;
    for (auto t : cnt) {
      if (t.first >= b[x]) break;
      if (t.second == 1)
        un++;
      else
        non++;
    }
    memset(aa, 0, sizeof(aa));
    memset(bb, 0, sizeof(bb));
    vector<long long> p1 = newtonExp(2, 1, un);
    vector<long long> p2 = newtonExp(1, 1, non * 2);
    int sz = multiply(p1, p2);
    for (int i = 0; i < q; ++i) {
      int t = Q[i] - b[x] - 1;
      if (t >= 0 && t < sz) {
        ret[i] = norm(ret[i] + aa[t]);
      }
    }
  }
  for (int i = 0; i < q; ++i) {
    printf("%d\n", ret[i]);
  }
}
int main() {
  solve();
  return 0;
}
