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 ** 9

for bit in range(1, 2 ** 10):
    cc = 0
    for i in range(n):
        c = 0
        for j in range(10):
            if bit & (1<<j) and f[i][j]:
                c += 1
        cc += p[i][c]
    ans = max(ans, cc) 
print(ans)