#include <bits/stdc++.h>
using namespace std;
using LL = long long;
int modpow(int a, int n, int mod) {
  int res = 1;
  for (; n > 0; n /= 2) {
    if (n & 1) res = (res * 1ll * a) % mod;
    a = (a * 1ll * a) % mod;
  }
  return res;
}
const int mod = 998244353;
const int root = 363395222;
const int root_1 = 704923114;
const int root_pw = 1 << 19;
const int root_pw_1 = 998242449;
void fft(vector<int>& a, bool invert = false) {
  const int n = root_pw;
  for (int i = 1, j = 0; i < n; i++) {
    int bit = n >> 1;
    for (; j & bit; bit >>= 1) j ^= bit;
    j ^= bit;
    if (i < j) swap(a[i], a[j]);
  }
  for (int len = 2; len <= n; len <<= 1) {
    int wlen = invert ? root_1 : root;
    for (int i = len; i < root_pw; i <<= 1)
      wlen = (int)(1LL * wlen * wlen % mod);
    for (int i = 0; i < n; i += len) {
      int w = 1;
      for (int j = 0; j < len / 2; j++) {
        int u = a[i + j], v = (int)(1LL * a[i + j + len / 2] * w % mod);
        a[i + j] = u + v < mod ? u + v : u + v - mod;
        a[i + j + len / 2] = u - v >= 0 ? u - v : u - v + mod;
        w = (int)(1LL * w * wlen % mod);
      }
    }
  }
  if (invert) {
    for (int& x : a) x = (int)(1LL * x * root_pw_1 % mod);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, k;
  cin >> n >> k;
  map<int, int> f;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    f[x]++;
  }
  vector<int> h(k);
  vector<vector<int>> res(k);
  for (int i = 0; i < k; i++) {
    cin >> h[i];
    int ones = 0, twos = 0;
    for (auto e : f) {
      if (e.first < h[i]) {
        if (e.second == 1)
          ones++;
        else
          twos++;
      }
    }
    vector<int> p1(root_pw);
    p1[0] = 1, p1[1] = 2;
    fft(p1);
    vector<int> p2(root_pw);
    p2[0] = 1, p2[1] = 2, p2[2] = 1;
    fft(p2);
    res[i].resize(root_pw);
    for (int j = 0; j < root_pw; j++) {
      res[i][j] =
          (modpow(p1[j], ones, mod) * 1ll * modpow(p2[j], twos, mod)) % mod;
    }
    fft(res[i], true);
    ;
  }
  int q;
  cin >> q;
  while (q--) {
    int p;
    cin >> p;
    int ans = 0;
    for (int i = 0; i < k; i++) {
      int j = p / 2 - h[i] - 1;
      if (j >= 0 && j <= n) {
        ans = (ans + res[i][j]) % mod;
      }
    }
    cout << ans << '\n';
  }
  return 0;
}
