n = int(input())
f = []
p = []

for i in range(n):
    f.append(list(map(int,input().split())))

for i in range(n):
    p.append(list(map(int,input().split())))

ans = -10**9
for i in range(1,2**11): #ビット全探索 
    opn = [0 for i in range(10)]
    scr = 0

    for j in range(10):
        memo = (i>>j)
    
    

        if memo&1:
            opn[j] = 1
    
    for k in range(n):
        cnt = 0
        for l in range(10):
            if opn[l] and f[k][l]:
                cnt += 1
        scr += p[k][cnt]

    ans = max(scr,ans)

print(ans)