import itertools

N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

ans = -10 ** 10
for f in list(itertools.product([0, 1], repeat=10))[1:]:
    p = sum([P[i][sum([F[i][j] * f[j] for j in range(10)])] for i in range(N)])
    ans = max(ans, p)

print(ans)
