from collections import deque N,F=map(int,input().split()) A=list(map(int,input().split())) B=list(map(int,input().split())) C=list(map(int,input().split())) l = [deque() for _ in range(61)] use = [False for _ in range(N*F+1)] use[A[0]]=True use[B[0]]=True use[C[0]]=True c=len({A[0],B[0],C[0]}) ans=[c] for j in range(61): for u in {A[0],B[0],C[0]}: l[j].append(u) for i in range(1,N): new=[] for d in {A[i],B[i],C[i]}: while len(l[d]) != 0: x = l[d].popleft() if not use[x+d]: use[x+d]=True new.append(x+d) c+=1 for n in new: for j in range(61): l[j].append(n) ans.append(c) print(*ans,sep="\n")