#ABC080C
import numpy as np
N=int(input())
F = []
for i in range(N):
    F.append(list(map(int, input().split())))
P = []
for i in range(N):
    P.append(list(map(int, input().split())))

ans=-1*pow(10,7)
ans_tmp=0
Self=[0]*10
c=0
#営業時間を仮定
for i in range(pow(2,10)-1):
    ans_tmp=0
    if i !=0:
        i_tmp = i
        for j in range(10):
            Self[j]=i_tmp//pow(2,9-j)
            i_tmp-=Self[j]*pow(2,9-j)
        for k in range(N):
            c=np.dot(F[k],Self)
            ans_tmp+=P[k][c]
        if ans<ans_tmp:
            ans=ans_tmp
print(ans)