N,F = map(int,input().split()) A = list(map(int,input().split())) B = list(map(int,input().split())) C = list(map(int,input().split())) now = 1 for i in range(N): a,b,c = A[i],B[i],C[i] now = (now << a) | (now << b) | (now << c) print(now.bit_count())