import std.algorithm, std.conv, std.range, std.stdio, std.string; import std.bitmanip; // BitArray void main() { auto rd = readln.split.to!(size_t[]), l = rd[0], m = rd[1], n = rd[2]; auto ai = readln.split.to!(int[]); auto bi = readln.split.to!(int[]); auto q = readln.chomp.to!int; auto bai = BitArray(); bai.length = n+1; foreach (a; ai) bai[a] = true; auto bbi = BitArray(); bbi.length = n+1; foreach (b; bi) bbi[b] = true; foreach (_; 0..q) { auto bci = bai & bbi; writeln((cast(size_t[])(bci)).map!(i => i.popcnt).sum); bbi <<= 1; } } pragma(inline) { import core.bitop; pure int popcnt(T)(T n) { return core.bitop.popcnt(ulong(n)); } }