#include <bits/stdc++.h>
using namespace std;
template <typename T = long long>
inline T read() {
  T s = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    s = (s << 3) + (s << 1) + ch - 48;
    ch = getchar();
  }
  return s * f;
}
namespace IO {
template <typename T>
inline void w(T x) {
  if (x > 9) w(x / 10);
  putchar(x % 10 + 48);
}
template <typename T>
inline void write(T x, char c) {
  if (x < 0) putchar('-'), x = -x;
  w(x);
  putchar(c);
}
template <typename T>
inline void read(T &x) {
  x = 0;
  T f = 1;
  char c = getchar();
  for (; !isdigit(c); c = getchar())
    if (c == '-') f = -1;
  for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
  x *= f;
}
};  // namespace IO
const int N = 3e5 + 5, MAXN = 3e5 + 5, MOD = 1e9 + 7, CM = 998244353,
          INF = 0x3f3f3f3f;
namespace NTT {
long long ksm(long long a, long long b, long long p) {
  long long ans = 1;
  a %= p;
  while (b) {
    if (b & 1) ans = ans * a % p;
    a = a * a % p;
    b >>= 1;
  }
  return ans;
}
const int P = 998244353, G = 3, inv_G = 332748118;
const int N = 2e6 + 5;
int r[N], A[N], B[N], n, m;
void NTT(int *a, int n, int op) {
  for (int i = 0; i < n; i++)
    if (i < r[i]) swap(a[i], a[r[i]]);
  for (int mid = 1; mid < n; mid <<= 1) {
    int x = ksm(op == 1 ? G : inv_G, (P - 1) / (mid << 1), P);
    for (int j = 0; j < n; j += (mid << 1)) {
      int w = 1;
      for (int k = 0; k < mid; k++, w = 1ll * w * x % P) {
        int t1 = a[j + k], t2 = 1ll * w * a[j + k + mid] % P;
        a[j + k] = (t1 + t2) % P;
        a[j + k + mid] = (t1 - t2 + P) % P;
      }
    }
  }
  if (op == -1) {
    int inv = ksm(n, P - 2, P);
    for (int i = 0; i <= n; i++) A[i] = 1ll * A[i] * inv % P;
  }
}
void mul(int *a, int *b, int *c, int nn, int mm, int &k) {
  int l = 0;
  n = nn, m = mm;
  for (m = n + m, n = 1; n <= m; n <<= 1, l++)
    ;
  for (int i = 0; i < n; i++) {
    r[i] = (r[i >> 1] >> 1) | ((i & 1) << (l - 1));
    A[i] = B[i] = 0;
  }
  for (int i = 0; i <= nn; i++) A[i] = a[i];
  for (int i = 0; i <= mm; i++) B[i] = b[i];
  NTT(A, n, 1);
  NTT(B, n, 1);
  for (int i = 0; i < n; i++) A[i] = 1ll * A[i] * B[i] % P;
  NTT(A, n, -1);
  k = m;
  for (int i = 0; i <= m; i++) c[i] = A[i];
}
};  // namespace NTT
long long ksm(long long a, long long b, long long p) {
  long long ans = 1;
  a %= p;
  while (b) {
    if (b & 1) ans = ans * a % p;
    a = a * a % p;
    b >>= 1;
  }
  return ans;
}
namespace Combination {
long long fac[MAXN], invfac[MAXN], mod;
void init(int n, long long MOD) {
  fac[0] = 1;
  mod = MOD;
  for (int i = 1; i <= n; i++) fac[i] = fac[i - 1] * i % mod;
  invfac[n] = ksm(fac[n], mod - 2, mod);
  for (int i = n; i >= 1; i--) invfac[i - 1] = invfac[i] * i % mod;
}
long long C(long long n, long long m) {
  return n >= m ? fac[n] * invfac[n - m] % mod * invfac[m] % mod : 0;
}
}  // namespace Combination
int a[N], b[N], cnt[N], n, k;
int ans[N][6];
int aa[N], bb[N], cc[N];
void cal(int pos, int red) {
  int one = 0, two = 0;
  for (int i = 1; i < red; i++) one += cnt[i] == 1, two += cnt[i] >= 2;
  two *= 2;
  for (int i = 0; i <= one; i++)
    aa[i] = 1ll * ksm(2, i, CM) * Combination::C(one, i) % CM;
  for (int i = 0; i <= two; i++) bb[i] = Combination::C(two, i);
  int three = 0;
  NTT::mul(aa, bb, cc, one, two, three);
  for (int i = 0; i <= three; i++) ans[i][pos] = cc[i];
}
void solve(int kase) {
  Combination::init(N - 4, CM);
  n = read(), k = read();
  for (int i = 1; i <= n; i++) a[i] = read();
  for (int i = 1; i <= n; i++) cnt[a[i]]++;
  for (int i = 1; i <= k; i++) b[i] = read();
  for (int i = 1; i <= k; i++) cal(i, b[i]);
  int q = read();
  for (int i = 1; i <= q; i++) {
    int Q = read();
    int res = 0;
    for (int j = 1; j <= k; j++) {
      int num = Q / 2 - b[j] - 1;
      if (num < 0) continue;
      res += ans[num][j];
      res %= CM;
    }
    IO::write(res, '\n');
  }
}
const bool DUO = 0;
int main() {
  clock_t start, finish;
  double totaltime;
  start = clock();
  if (DUO) {
    int Kase = 0;
    cin >> Kase;
    for (int kase = 1; kase <= Kase; kase++) solve(kase);
  } else
    solve(1);
  finish = clock();
  return 0;
  printf("\nTime: %lfms\n", (double)(finish - start) / CLOCKS_PER_SEC * 1000);
  return 0;
}
