# coding :utf-8
N=int(input())

F=[]
P=[]

table = [2**i for i in range(10)]


for i in range(N):
    lis = list(map(int, input().split()))
    F.append(lis)
#print(F)
for i in range(N):
    lis = list(map(int, input().split()))
    P.append(lis)
#print(P)

maxx=-1000000000001
total=0

for i in range(1,1024):
    for j in range(N):
        for k in range(10):
            n=0
            n +=(1 if i&table[k] !=0 else 0)*F[j][k]
        total += P[j][n]
    if total >maxx:
        maxx= total
print(maxx)