import itertools

N=int(input())
F=[list(map(int,input().split())) for i in range(N)]
P=[list(map(int,input().split())) for i in range(N)]

bit=list(itertools.product([0,1], repeat=10))
bit.pop(0)
ans=-10**10

for i in range(1023):
    a=0
    for j in range(N):
        t=sum([F[j][k]*bit[i][k] for k in range(10)])
        a+=P[j][t]
    ans=max(a,ans)

print(ans)