from itertools import product

n = int(input())
f_all = []
for i in range(n):
    fi = list(map(int, input().split()))
    f_all.append(fi)
p_all = []
for i in range(n):
    pi = list(map(int, input().split()))
    p_all.append(pi)

res = -999999999
for pro in product([0, 1], repeat=10):
    if sum(pro) == 0:
        continue
    total = 0
    for i in range(n):
        count = 0
        for j in range(10):
            if pro[j] == 1 and f_all[i][j] == 1:
                count += 1
        total += p_all[i][count]
    res = max(res, total)
print(res)