#include "bits/stdc++.h" using namespace std; int bitcount(long long bits){ bits = (bits & 0x5555555555555555) + (bits >> 1 & 0x5555555555555555); bits = (bits & 0x3333333333333333) + (bits >> 2 & 0x3333333333333333); bits = (bits & 0x0f0f0f0f0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f0f0f0f0f); bits = (bits & 0x00ff00ff00ff00ff) + (bits >> 8 & 0x00ff00ff00ff00ff); bits = (bits & 0x0000ffff0000ffff) + (bits >> 16 & 0x0000ffff0000ffff); return (bits & 0x00000000ffffffff) + (bits >> 32 & 0x00000000ffffffff); } int main() { int L, M, N; cin >> L >> M >> N; vector A(L); vector B(M); vector Bpos(N + 10000); for (int i = 0; i < L; i++) { cin >> A[i]; A[i]--; } for (int i = 0; i < M; i++) { cin >> B[i]; B[i]--; Bpos[B[i]]++; } sort(A.begin(), A.end()); sort(B.begin(), B.end()); int Q; cin >> Q; vector ans(N + Q + 100, 0); for (int j = 0; j < 60; j++) { vector al(N / 60 + 100); for (int i = 0; i < A.size(); i++) { if (A[i] < j) continue; al[(A[i] - j) / 60] |= 1ll << ((A[i] - j) % 60); } for (int i = 0; i < (N - j + 59) / 60; i++) { long long bit = 0; for (int k = 0; k < 60; k++) { if (Bpos[i * 60 + k] == 1){ bit |= 1ll << k; } } for (int k = i; k < (N - j + 59) / 60; k++) { ans[j + (k - i) * 60] += bitcount(al[k] & bit); } } } for (int i = 0; i < Q; i++) { cout << ans[i] << endl; } cin >> N; }