import itertools
n=int(input())
lf=[list(map(int,input().split())) for _ in range(n)]
lp=[list(map(int,input().split())) for _ in range(n)]
lit=list(itertools.product([0,1],repeat=10))[1:]
ans=-10**9
for i in lit:
    tmp=0
    for num,j in enumerate(lf):
        com=sum([k*l for k,l in zip(i,j)])
        tmp+=lp[num][com]
    ans=max(ans,tmp)
print(ans)