import itertools
j_shop = list(set(itertools.product(*[[0, 1]]*10)) - set([tuple([0]*10)]))

n = int(input())

D = [[] for _ in range(10)]
from collections import defaultdict
profit = defaultdict(int)


for i in range(n):
    f = list(map(int, input().split()))
    for j in range(10):
        if f[j] == 1:
            D[j].append(i)
            
for i in range(n):
    p = list(map(int, input().split()))
    for j in range(11):
        profit[(i, j)] = p[j]
        
ans = float('-INF')
for js in j_shop:
    temp = defaultdict(int)
    for i in range(10):
        if js[i] == 1:
            for d in D[i]:
                temp[d] += 1
    p = 0
    for k, v in temp.items():
        p += profit[(k, v)]
    ans = max(ans, p)
    
print(ans)