#include <bits/stdc++.h>
using namespace std;
long long int INF = 1e17;
const long long fact_table = 800008;
double Pi = 3.1415926535897932384626;
priority_queue<long long> pql;
priority_queue<pair<long long, long long> > pqp;
priority_queue<long long, vector<long long>, greater<long long> > pqls;
long long dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
long long dy[8] = {0, 1, 0, -1, 1, -1, -1, 1};
char dir[] = "DRUL";
long long mod = 998244353;
long long rui(long long number1, long long number2) {
  if (number2 == 0) {
    return 1;
  } else {
    long long number3 = rui(number1, number2 / 2);
    number3 *= number3;
    number3 %= mod;
    if (number2 % 2 == 1) {
      number3 *= number1;
      number3 %= mod;
    }
    return number3;
  }
}
long long gcd(long long number1, long long number2) {
  if (number1 > number2) {
    swap(number1, number2);
  }
  if (number1 == 0 || number1 == number2) {
    return number2;
  } else {
    return gcd(number2 % number1, number1);
  }
}
void YES(bool condition) {
  if (condition) {
    cout << "YES"
         << "\n";
    ;
  } else {
    cout << "NO"
         << "\n";
    ;
  }
  return;
}
void Yes(bool condition) {
  if (condition) {
    cout << "Yes"
         << "\n";
    ;
  } else {
    cout << "No"
         << "\n";
    ;
  }
  return;
}
long long fact[fact_table + 5], rfact[fact_table + 5];
void c3_init() {
  fact[0] = rfact[0] = 1;
  for (long long i = 1; i <= fact_table; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
  rfact[fact_table] = rui(fact[fact_table], mod - 2);
  for (long long i = fact_table; i >= 1; i--) {
    rfact[i - 1] = rfact[i] * i;
    rfact[i - 1] %= mod;
  }
  return;
}
long long c3(long long n, long long r) {
  return (((fact[n] * rfact[r]) % mod) * rfact[n - r]) % mod;
}
namespace NTT {
void DFT(long long m, long long root, vector<long long> &a, bool rev = false) {
  long long N = a.size(), h = 0;
  for (long long i = 0; 1 << i < N; i++) h++;
  for (long long i = 0; i < N; i++) {
    long long j = 0;
    for (long long k = 0; k < h; k++) j |= (i >> k & 1) << (h - 1 - k);
    if (i < j) swap(a[i], a[j]);
  }
  for (long long i = 1; i < N; i *= 2) {
    long long base = rui(root, (m - 1) / i / 2);
    if (rev) base = rui(base, m - 2);
    long long w = 1;
    for (long long j = 0; j < i; j++) {
      for (long long k = 0; k < N; k += i * 2) {
        long long s = a[j + k], t = a[j + k + i] * w % m;
        a[j + k + 0] = (s + t) % m;
        a[j + k + i] = (s - t + m) % m;
      }
      w = w * base % m;
    }
  }
  if (rev) {
    long long tmp = rui(N, m - 2);
    for (long long &v : a) v = v * tmp % m;
  }
}
vector<long long> conv(long long _mod, long long root,
                       const vector<long long> &a, const vector<long long> &b) {
  long long s = 1, t = a.size() + b.size() - 1;
  while (s < t) s *= 2;
  vector<long long> F(s), G(s);
  for (long long i = 0; i < (long long)a.size(); i++) F[i] = a[i];
  for (long long i = 0; i < (long long)b.size(); i++) G[i] = b[i];
  DFT(_mod, root, F);
  DFT(_mod, root, G);
  for (long long i = 0; i < s; i++) F[i] = (long long)F[i] * G[i] % _mod;
  DFT(_mod, root, F, true);
  return F;
}
};  // namespace NTT
long long n, m, num, sum, a, b, c, d, e, h, r, l, q;
long long k;
long long white[500005], red[500005];
long long ans[500005];
long long query[500005];
int main() {
  cin >> n >> k;
  c3_init();
  for (long long i = 0; i < n; i++) {
    cin >> white[i];
  }
  for (long long i = 0; i < k; i++) {
    cin >> red[i];
  }
  cin >> q;
  for (long long i = 0; i < q; i++) {
    cin >> query[i];
  }
  sort(white, white + n);
  reverse(white, white + n);
  long long cnt = 1;
  vector<pair<long long, long long> > table;
  for (long long i = 0; i < n; i++) {
    if (white[i] != white[i + 1] || i == n - 1) {
      table.push_back(pair<long long, long long>(white[i], cnt));
      cnt = 1;
    } else {
      cnt++;
    }
  }
  for (long long i = 0; i < k; i++) {
    long long a = 0, b = 0;
    for (long long j = 0; j < table.size(); j++) {
      if (table[j].first >= red[i]) continue;
      if (table[j].second >= 2) b++;
      if (table[j].second == 1) a++;
    }
    vector<long long> atable, btable;
    for (long long j = 0; j <= a; j++) {
      long long tmp = c3(a, j) * rui(2, j);
      tmp %= mod;
      atable.push_back(tmp);
    }
    for (long long j = 0; j <= 2 * b; j++) {
      long long tmp = c3(2 * b, j);
      btable.push_back(tmp);
    }
    auto res = NTT::conv(mod, 3ll, atable, btable);
    for (long long j = 0; j < q; j++) {
      long long cnt = query[j] / 2 - red[i] - 1;
      if (cnt < 0) continue;
      if (cnt > a + b * 2) continue;
      ans[j] += res[cnt];
      ans[j] %= mod;
    }
  }
  for (long long i = 0; i < q; i++) {
    cout << ans[i] << "\n";
    ;
  }
  return 0;
}
