
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 ** 7
for i in range(1, 2 ** 10):
    calc = 0
    for j in range(n):
        cnt = 0
        for k in range(10):
            if i >> k & 1 and f[j][k] == 1:
                cnt += 1
        calc += p[j][cnt]
                
    ans = max(ans, calc)

print(ans)
            