#include #include #define M_PI 3.14159265358979323846 // pi using namespace std; using ll = long long; using ull = unsigned long long; using P = pair; using t3 = tuple; using t4 = tuple; using t5 = tuple; #define rep(a,n) for(ll a = 0;a < n; a++) #define rrep(a,n) for(ll a = n-1;a >= 0; a--) using namespace atcoder; template static void chmin(T& ref, const T value) { if (ref > value) ref = value; } template static void chmax(T& ref, const T value) { if (ref < value) ref = value; } template static void chmax(map& ref, const TKey& key, const T& value) { if (ref.count(key)) { chmax(ref[key], value); return; } ref[key] = value; } typedef modint998244353 mint; constexpr ll mod = 998244353; static constexpr ll mpow(ll x, ll n) { ll ans = 1; x %= mod; while (n != 0) { if (n & 1) ans = ans * x % mod; x = x * x % mod; n = n >> 1; } return ans; } static constexpr ll inv_mod(ll a) { return mpow(a, mod - 2); } class Factorial { private: vector fac; vector ifac; public: Factorial(ll N) { fac.push_back(1); for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod); ifac.resize(N + 1); ifac[N] = inv_mod(fac[N]); for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod; } ll fact(ll a) { return fac[a]; } ll ifact(ll a) { return ifac[a]; } ll cmb(ll a, ll b) { if (a == 0 && b == 0) return 1; if (a < b || a < 0 || b < 0) return 0; ll tmp = ifact(a - b) * ifact(b) % mod; return tmp * fac[a] % mod; } ll per(ll a, ll b) { if (a == 0 && b == 0) return 1; if (a < b || a < 0 || b < 0) return 0; return fac[a] * ifac[a - b] % mod; } }; class Primes { private: vector Prime_Number; vector is_prime_; public: Primes(int N) { is_prime_.resize(N + 1, true); is_prime_[0] = is_prime_[1] = false; for (int i = 0; i < N + 1; i++) { if (is_prime_[i]) { Prime_Number.push_back(i); for (int j = 2 * i; j <= N; j += i) is_prime_[j] = false; } } } int operator[](int i) { return Prime_Number[i]; } int size() { return Prime_Number.size(); } int back() { return Prime_Number.back(); } bool isPrime(int q) { return is_prime_[q]; } }; class Divisor { private: vector F; vector> pfactorize; public: Divisor(ll N) { for (ll i = 1; i * i <= N; i++) { if (N % i == 0) { F.push_back(i); if (i * i != N) F.push_back(N / i); } } sort(begin(F), end(F)); Primes p((ll)sqrt(N) + 1); for (int i = 0; i < p.size(); i++) { pfactorize.emplace_back(p[i], 0); while (N % p[i] == 0) { N /= p[i]; pfactorize.back().second++; } if (pfactorize.back().second == 0) pfactorize.pop_back(); } if (N > 1) pfactorize.emplace_back(N, 1); } int size() { return F.size(); } const vector>& pfac() { return pfactorize; } ll operator[](int k) { return F[k]; } const vector& factors() { return F; } }; struct warshall_floyd { static void solve(vector>& d) { int n = d.size(); rep(k, n) { rep(i, n) { rep(j, n) { d[i][j] = min(d[i][j], d[i][k] + d[k][j]); } } } } }; struct topoloricalSort_runnner2 { vector input; ll topologicalSort( const vector>& graph, vector vCounts) { int n = graph.size(); //入次数 input.assign(n, 0); rep(i, n) { for (auto dest : graph[i]) { input[dest]++; } } queue q; rep(i, n) { if (input[i] == 0) { q.push(i); } } ll sum = 0; vector add(n, 0); while (!q.empty()) { auto from = q.front(); q.pop(); for (auto next : graph[from]) { //すべての親を処理し終わったら処理する sum += vCounts[next] * vCounts[from]; add[next]+= vCounts[from]; input[next]--; if (input[next] == 0) { vCounts[next] += add[next]; q.push(next); } } } return sum; } }; int main() { ll l, m, n; cin >> l >> m >> n; vector as(l), bs(m); rep(i, l)cin >> as[i]; rep(i, m)cin >> bs[i]; bitset<(ll)1e5+1> bit1, bit2; rep(i, l){ bit1.set(as[i]); } rep(i, m){ bit2.set(bs[i]); } ll q; cin >> q; rep(i, q){ auto b3 = bit1 & bit2; cout << b3.count() << endl; bit2 <<= 1; } return 0; }