import sys #input = sys.stdin.readline input = sys.stdin.buffer.readline #文字列はダメ #sys.setrecursionlimit(1000000) #import bisect #import itertools #import random #from heapq import heapify, heappop, heappush #from collections import defaultdict #from collections import deque #import copy #import math #from functools import lru_cache #@lru_cache(maxsize=None) #MOD = pow(10,9) + 7 #MOD = 998244353 #dx = [1,0,-1,0] #dy = [0,1,0,-1] import numpy as np def convolve(f, g): """多項式 f, g の積を計算する。 Parameters ---------- f : np.ndarray (int64) f[i] に、x^i の係数が入っている g : np.ndarray (int64) g[i] に、x^i の係数が入っている Returns ------- h : np.ndarray f,g の積 """ # h の長さ以上の n=2^k を計算 fft_len = 1 while 2 * fft_len < len(f) + len(g) - 1: fft_len *= 2 fft_len *= 2 # フーリエ変換 Ff = np.fft.rfft(f, fft_len) Fg = np.fft.rfft(g, fft_len) # 各点積 Fh = Ff * Fg # フーリエ逆変換 h = np.fft.irfft(Fh, fft_len) # 小数になっているので、整数にまるめる h = np.rint(h).astype(np.int64) return h[:len(f) + len(g) - 1] def main(): L,M,N = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) Q = int(input()) MAX = pow(10,5) + 10 #AX[i]:0/1 iとなる値がAに入っているか否か AX = [0]*MAX BX = [0]*MAX for a in A: AX[a] = 1 for b in B: BX[b] = 1 BXR = list(reversed(BX)) #print(AX) #print(BXR) #BXにqを足してAXと同じになるものが欲しい。、 #AX[i] * BX[i-q]の係数が欲しいもの。 #Bを反転させるとBXR[N-1-i+q]となる。 #iとi+qの関係が、iとN-1+q-iとなるので、和がN-1+qのところを見ればよい。 D = convolve(AX,BXR) #print(D) for v in range(Q): ans = D[MAX-1+v] print(ans) if __name__ == '__main__': main()