N = int(input())
F = [[int(x) for x in input().split()] for _ in range(N)]
P = [[int(x) for x in input().split()] for _ in range(N)]


ans = -1 << 40
for mask in range(1, 1 << 10):
    t = 0
    for i in range(N):
        c = 0
        for j in range(10):
            if (mask >> j) & F[i][j]:
                c += 1
        t += P[i][c]
    ans = max(ans, t)

print(ans)
