f = lambda: list(map(int,input().split()))

n = int(input())
F = [f() for _ in range(n)]
P = [f() for _ in range(n)]

from itertools import product
mul = product((0, 1), repeat=10)

ans = -float('inf')
for m in mul:
    ben = 0
    for shop in range(n):
        op = sum(m[j] & F[shop][j] for j in range(10))
        ben += P[shop][op]
    ans = max(ans,ben)
print(ans)