N = int(input())

F = []
for i in range(N):
    f = list(map(int, input().split()))
    F.append(f)

P = []
for i in range(N):
    p = list(map(int, input().split()))
    P.append(p)

import itertools

data = [0,1,2,3,4,5,6,7,8,9]

ans_max = -10**7


for i in range(1,11):
    for s in list(itertools.combinations(data,i)):
        ans = 0
        
        a = [0,0,0,0,0,0,0,0,0,0]
                
        for j in s:
            a[j]=1
        
        for k in range(N):
            cnt = 0
            for l in range(10):
                if F[k][l] == a[l] and a[l]==1:
                    cnt += 1
            ans += P[k][cnt]
        if ans > ans_max:
            ans_max = ans

print(ans_max)

