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)]

# print(f)
# print(p)
ans=-(10**8)

for i in range(1,2**10):
    list=[0]*n
    earn=0
    for j in range(10):
        for k in range(n):
            if i&(1<<j) and f[k][j]==1:
                list[k]+=1
    
    for k in range(n):
        earn+=p[k][list[k]]
    
    ans=max(ans, earn)
print(ans)