n = int(input())
f = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(n)]

ans = -float("inf")
for i in range(1, 2 ** 10):
    res = 0
    for j in range(n):
        cnt = sum([(i >> k & 1) & f[j][k] for k in range(10)])
        res += p[j][cnt]
    ans = max(ans, res)

print(ans)
