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(L[i],v,cnt,i,score,score[i][cnt])
        if cnt > 0:
            sc += score[i][cnt]
            #print(L[i],v,cnt,i,score,score[i][cnt])
    if cnt > 0:
        ans = max(ans,sc)

print(ans)