#080_C
n=int(input())
f=[list(map(int,input().split())) for _ in range(n)]
p=[list(map(int,input().split())) for _ in range(n)]
ans=0

for i in range(2**10):
    l=[]
    for j in range(10):
        if (i>>j)&1:
            l.append(1)
        else:
            l.append(0)
    res=0       
    for j in range(n):
        res+=p[j][sum([f[j][k]*l[k] for k in range(10)])]
    ans=max(ans,res)
    
print(ans)