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**15
for i in range(1, 2**10):
    tmp = 0
    for k in range(N):
        c = 0
        for j in range(10):
            if (i >> j) & 1 and F[k][j]:
                c += 1
        tmp += P[k][c]
    ans = max(ans, tmp)
print(ans)