n = int(input())
L,score = [],[]
for i in range(n):
    L.append(list(map(int,input().split())))
for i in range(n):
    score.append(list(map(int,input().split())))
#print(L,score)
from itertools import product

ans = -10**32

for v in product([0,1],repeat = 10):
    #print(v)
    sc = 0
    
    for i in range(n):
        cnt = 0
        for j in range(10):
            if (L[i][j] == 1 and v[j] == 1):
                cnt +=1
                #print(i,j,cnt,L[i],v[j],v)
        #print(L[i],v,cnt,i)

        sc += score[i][cnt]
    ans = max(ans,sc)

print(ans)