import sys
input = sys.stdin.readline

N = int(input().strip())

openhour = [0] * 10
samehour = [0] * N

F = [0] * N
P = [0] * N
for i in range(N):
    F[i] = [int(x) for x in input().strip().split()]
for i in range(N):
    P[i] = [int(x) for x in input().strip().split()]

def f(i, openhour, samehour):
    if i == 10:
        if sum(openhour) == 0:
            return - 10 ** 9 + 7
        global N, F, P
        ret = sum([P[n][samehour[n]] for n in range(N)])
        return ret
    oh1 = openhour[:]
    oh2 = openhour[:]
    oh1[i] = 0
    oh2[i] = 1
    sh2 = samehour[:]
    for n in range(N):
        if F[n][i] == 1:
            sh2[n] += 1

    return max(f(i+1, oh1[:], samehour[:]),f(i+1, oh2[:], sh2[:]))

print(f(0, openhour[:], samehour[:]))

