n = int(input())
f = [list(map(int, input().split())) for i in range(n)]
p = [list(map(int, input().split())) for i in range(n)]
ans = -float("inf")
for bit in range(1, 1 << 10):
    cc = 0
    for i in range(n):
        c = 0
        for j in range(10):
            if (bit >> j & 1) and f[i][j]:
                c += 1
        cc += p[i][c]
    ans = max(ans, cc)
print(ans)