# ABC 080 
def getIntList(): return [int(x) for x in input().split()]
def zeros(n): return [0 for i in range(n)]

N = int(input())
F = []
for i in range(N):
    F.append(getIntList())
#print(F)#
P = []
for i in range(N):
    P.append(getIntList())
#print(P)#

maxProf = -10**8
for n in range(1,2**10):
    a = zeros(10)
    m = n
    for i in range(10):
        a[i] = m % 2
        m //= 2
    prof = 0
    for i in range(N):
        c = 0
        for j in range(10):
            c += a[j]*F[i][j]
        prof += P[i][c]
    if prof>maxProf: maxProf = prof
print(maxProf)