N=int(input())
F=[]
P=[]
ff=0
while ff < N:
    f=list(map(int,input().split(' ')))
    F.append(f)
    ff += 1
pp=0
while pp < N:
    p=list(map(int,input().split(' ')))
    P.append(p)
    pp += 1
def plus1(test,j):
    if test[j]==0:
        test[j]=1
    else:
        test[j]=0
        plus1(test,j+1)
test=[0,0,0,0,0,0,0,0,0,0]
k=0
Ans=-1e+8
while k<1023:
    plus1(test,0)
    i=0
    ev=0
    while i < N:
        l=0
        for q in range(0,10):
            if F[i][q]==1 and test[q]==1:
                l+=1
        ev += P[i][l]
        i+=1
    if Ans < ev:
        Ans=ev
    k+=1
print(Ans)