#include using namespace std; typedef long long ll; typedef vector< int > vi; typedef vector< vi > vvi; typedef vector< ll > vl; typedef vector< vl > vvl; typedef pair< int, int > pii; typedef vector< pii > vp; typedef vector< double > vd; typedef vector< vd > vvd; typedef vector< string > vs; template< class T1, class T2 > int upmin( T1 &x, T2 v ){ if( x > v ){ x = v; return 1; } return 0; } template< class T1, class T2 > int upmax( T1 &x, T2 v ){ if( x < v ){ x = v; return 1; } return 0; } const int INF = 0x3f3f3f3f; int L, M, N; vi A; vi B; int Q; void init(){ cin >> L >> M >> N; A = vi( L ); for( int i = 0; i < L; ++i ) cin >> A[ i ], --A[ i ]; B = vi( M ); for( int i = 0; i < M; ++i ) cin >> B[ i ], --B[ i ]; cin >> Q; } vi bit_a; vi bit_b; void preprocess(){ bit_a = bit_b = vi( ( N + 31 ) / 32 ); for( int i = 0; i < L; ++i ) bit_a[ i / 32 ] |= 1 << A[ i ] % 32; for( int i = 0; i < M; ++i ) bit_b[ i / 32 ] |= 1 << B[ i ] % 32; } void solve(){ for( int i = 0; i < Q; ++i ){ int ans = 0; for( int j = 0; j < bit_a.size(); ++j ){ int p = 32 * j + i; int x = p / 32, y = p % 32; int v = 0; if( x < bit_b.size() ) v = 1LL * bit_b[ x ] << y & ~0; if( y and x - 1 >= 0 ) v |= bit_b[ x - 1 ] >> 32 - y; ans += __builtin_popcount( bit_a[ j ] & v ); } cout << ans << endl; } } signed main(){ ios::sync_with_stdio( 0 ); init(); preprocess(); solve(); return 0; }