N=int(input())
F,P,F0=[],[],[]
ans=-10**8-1
for b in range(1,2**10):
    F0.append(format(b,'10b'))
for _ in range(N):
    F.append(list(input().split()))
for _ in range(N):
    P.append(list(map(int,input().split())))

for c in F0:
    benefit=0
    for i in range(N):
        counter=0
        for j in range(10):
            if c[j]=="1" and F[i][j]=="1":counter+=1
        benefit+=P[i][counter]
    ans=max(ans,benefit)

print(ans)