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)]
l=[0]*1024
for i in range(1024):
    I=format(i,'b').zfill(10)
    for k in range(n):
        c=0
        for j in range(10):
            if I[j]=='1' and f[k][j]==1:
                c+=1
        l[i]+=p[k][c]    
print(max(l[1:]))