n=int(input()) c=int(input()) v=int(input()) S=list(map(int,input().split())) T=list(map(int,input().split())) Y=list(map(int,input().split())) M=list(map(int,input().split())) z=zip(S,T,Y,M) d=[[None]*(c+1) for i in range(n)] d[0][0] = 0 for s,t,y,m in sorted(z,key=lambda x:(x[0],x[1])): for j in range(c+1): a=d[s-1][j] if a is not None: q=y+j if c