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)]
ans=float("-inf")
for i in range(1,2**10):
    i=list(map(int,list(bin(i)[2:].zfill(10))))
    x,y=0,0
    for j in range(n):
        y=0
        for k in range(10):
            if i[k]==f[j][k]==1:y+=1
        x+=p[j][y]
    ans=max(ans,x)
print(ans)