N, F = map(int, input().split()) A = list(map(int, input().split())) B = list(map(int, input().split())) C = list(map(int, input().split())) dp = 1 ans = [] for i in range(N): nxt = 0 nxt = nxt | (dp << A[i]) nxt = nxt | (dp << B[i]) nxt = nxt | (dp << C[i]) dp = nxt ans.append(dp.bit_count()) print(*ans, sep="\n")