#include <bits/stdc++.h>
using namespace std;
template <int mod>
struct modulo {
  int w;
  inline operator int &() { return w; }
  inline operator int() const { return w; }
  modulo() {}
  modulo(int w, bool f = 0) {
    this->w = w;
    if (f) fix();
  }
  void inline fix() {
    if (w >= mod || w < -mod) w %= mod;
    if (w < 0) w += mod;
  }
  modulo inline fix(int w) {
    if (w >= mod || w < -mod) w %= mod;
    if (w < 0) w += mod;
  }
  inline modulo operator-() {
    w = mod - w;
    return *this;
  }
  inline modulo operator+(const modulo &b) {
    modulo r = *this;
    return r += b;
  }
  inline modulo operator-(const modulo &b) {
    modulo r = *this;
    return r -= b;
  }
  inline modulo operator*(const modulo &b) {
    modulo r = *this;
    return r *= b;
  }
  inline modulo operator/(const modulo &b) {
    modulo r = *this;
    return r /= b;
  }
  inline modulo &operator+=(const modulo &b) {
    w += b.w;
    if (w >= mod) w -= mod;
    return *this;
  }
  inline modulo &operator-=(const modulo &b) {
    w -= b.w;
    if (w < 0) w += mod;
    return *this;
  }
  inline modulo &operator*=(const modulo &b) {
    w = (long long)w * b.w % mod;
    return *this;
  }
  inline modulo &operator/=(const modulo &b) { return *this *= inv(b); }
  friend inline modulo inv(const modulo &w) { return pow(w, mod - 2); }
  friend inline modulo pow(const modulo &w, int p) {
    if (w == 0) return 0;
    modulo a = w, r = 1;
    for (; p > 0; a *= a, p >>= 1)
      if (p & 1) r *= a;
    return r;
  }
};
const int mod = 998244353, p_rt = 3, dsz = 6e5;
template <class type>
struct fourier_transform;
template <class type>
struct poly;
template <class type>
struct fourier_transform {
  int sz, k, rev[dsz + 5];
  unsigned long long pw[dsz + 5], b[dsz + 5];
  void inline init(int to) {
    for (sz = 1, k = 0; sz <= to; sz <<= 1, ++k)
      ;
    if (!k) return;
    for (int i = 0; i < sz; ++i)
      rev[i] = rev[i >> 1] >> 1 | ((i & 1) << (k - 1));
  }
  void inline dft(poly<type> &a, int tp = 1) {
    a.set_deg(sz - 1);
    for (int i = 0; i < sz; ++i) {
      b[i] = a[i];
      if (i > rev[i]) swap(b[i], b[rev[i]]);
    }
    for (int len = 1; len < sz; len <<= 1) {
      unsigned long long w0 = pow(modulo<mod>(p_rt), (mod - 1) / (len << 1));
      if (tp == -1) w0 = inv(modulo<mod>(w0));
      pw[0] = 1;
      for (int i = 1; i <= len - 1; ++i) pw[i] = pw[i - 1] * w0 % mod;
      for (int l = 0; l < sz; l += len << 1) {
        unsigned long long *p0 = b + l, *p1 = b + l + len, *w = pw, tmp;
        for (int i = 0; i < len; ++i, ++p0, ++p1, ++w) {
          tmp = *w * *p1 % mod;
          *p1 = *p0 + mod - tmp;
          *p0 += tmp;
        }
      }
    }
    for (int i = 0; i < sz; ++i) a[i] = b[i] % mod;
    if (tp == 1) return;
    modulo<mod> iv = inv(modulo<mod>(sz));
    for (int i = 0; i < sz; ++i) a[i] *= iv;
  }
};
fourier_transform<modulo<mod> > ft;
template <class type>
struct poly {
  int deg;
  vector<type> d;
  poly() {}
  poly(vector<type> a) { deg = int(a.size()) - 1, d = a; }
  inline type &operator[](int id) { return d[id]; }
  inline type operator[](int id) const { return d[id]; }
  void inline set_deg(int deg) {
    this->deg = deg;
    d.resize(deg + 1, 0);
  }
  friend inline poly operator*(const poly &a, const poly &b) {
    poly f = a, g = b;
    ft.init(f.deg + g.deg);
    ft.dft(f), ft.dft(g);
    for (int i = 0; i < ft.sz; ++i) f[i] *= g[i];
    ft.dft(f, -1);
    f.set_deg(a.deg + b.deg);
    return f;
  }
};
const int nsz = 3e5, msz = 5;
int n, m, q, a[nsz + 5], b[msz + 5];
modulo<mod> fac[nsz + 5], ifc[nsz + 5];
vector<modulo<mod> > r[msz + 5];
modulo<mod> inline C(int n, int m) { return fac[n] * ifc[m] * ifc[n - m]; }
void inline solve(int a, int b, vector<modulo<mod> > &r) {
  poly<modulo<mod> > f, g;
  f.set_deg(a), g.set_deg(2 * b);
  for (int i = 0; i <= a; ++i) f[i] = C(a, i) * pow(modulo<mod>(2), i);
  for (int i = 0; i <= 2 * b; ++i) g[i] = C(2 * b, i);
  f = f * g;
  r = f.d;
}
void inline factorial_init(int to = nsz) {
  fac[0] = ifc[0] = 1;
  for (int i = 1; i <= to; ++i) fac[i] = fac[i - 1] * modulo<mod>(i);
  ifc[to] = inv(fac[to]);
  for (int i = to - 1; i >= 1; --i) ifc[i] = ifc[i + 1] * modulo<mod>(i + 1);
}
modulo<mod> inline qry(int k) {
  k >>= 1;
  modulo<mod> res = 0;
  for (int i = 1; i <= m; ++i) {
    int l = k - b[i] - 1;
    if (l < 0 || l >= r[i].size()) continue;
    res += r[i][l];
  }
  return res;
}
int main() {
  factorial_init();
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= m; ++i) scanf("%d", &b[i]);
  for (int i = 1; i <= m; ++i) {
    static int cnt[nsz + 5];
    int cur = b[i], ca = 0, cb = 0;
    for (int i = 1; i <= nsz; ++i) cnt[i] = 0;
    for (int i = 1; i <= n; ++i) {
      if (a[i] >= cur) continue;
      ++cnt[a[i]];
    }
    for (int i = 1; i <= nsz; ++i) ca += cnt[i] == 1, cb += cnt[i] > 1;
    solve(ca, cb, r[i]);
  }
  scanf("%d", &q);
  for (int i = 1; i <= q; ++i) {
    int k;
    scanf("%d", &k);
    printf("%d\n", qry(k).w);
  }
}
