#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(x, to) for (int x = 0; x < (to); x++) #define REP(x, a, to) for (int x = (a); x < (to); x++) #define foreach(itr, x) for (typeof((x).begin()) itr = (x).begin(); itr != (x).end(); itr++) using namespace std; typedef long long ll; typedef pair PII; typedef pair PLL; typedef unsigned long long ull; int L, M, N, Q; ull A[1605]; ull B[1605]; ull C[1605]; ull x; int SIZE = sizeof(ull)*8; int table16[(1<<16) + 5]; void solve() { #if 0 rep(i, 2) { rep(j, 64) { printf("%d", (A[i]&(1< 0); } } puts(""); #endif rep(i, Q) { int ans = 0; for (int j = 1600; j >= 0; j--) { if (i > 0) { B[j] <<= 1; if (j - 1 >= 0) { B[j] |= (B[j-1] & (1<<(SIZE-1))); } } C[j] = A[j] & B[j]; ans += table16[(C[j] & 0x000000000000ffffLL)]; ans += table16[(C[j] & 0x00000000ffff0000LL)>>16]; ans += table16[(C[j] & 0x0000ffff00000000LL)>>32]; ans += table16[(C[j] & 0xffff000000000000LL)>>48]; //cout << ans << endl; } cout << ans << endl; } } int main() { cin >> L >> M >> N; rep(i, L) { cin>> x; x--; A[x/SIZE] |= (1LL << (x % SIZE)); } rep(i, M) { cin>> x; x--; B[x/SIZE] |= (1LL << (x % SIZE)); } cin >> Q; rep(i, 1 << 16) { table16[i] = 0; rep(j, 16) { table16[i] += ((i & (1 << j)) > 0); } } solve(); return 0; }