module main; // https://yukicoder.me/problems/no/206/editorial より // ビット演算 import std; void main() { // 入力 int N, L, M; readln.chomp.formattedRead("%d %d %d", N, L, M); auto A = readln.split.to!(int[]); auto B = readln.split.to!(int[]); int Q = readln.chomp.to!int; // 答えの計算 auto bufX = new bool[](100_001); foreach (a; A) bufX[a] = true; auto X = BitArray(bufX); auto bufY = new bool[](100_001); foreach (b; B) bufY[b] = true; auto Y = BitArray(bufY); // 答えの出力 foreach (i; 0 .. Q) { writeln((X & Y).count); Y <<= 1; } }