N=int(input())
F=[[int(i) for i in input().split()] for j in range(N)]
P=[[int(i) for i in input().split()] for j in range(N)]
R=[]
for i in range(1,1024):
    opentime = [i>>k & 1 for k in range(10)]
    R.append(sum([P[shop][sum([i*j for i,j in zip(opentime,F[shop])])] for shop in range(N)]))
print(max(R))