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