N=int(input())
A=[list(map(int,input().split())) for i in range(N)]
B=[list(map(int,input().split())) for i in range(N)] 

import itertools
D=list(itertools.product([0,1],repeat=10))

ans=(-1)*99999999
for i in D:
  a=0
  if i!=(0,0,0,0,0,0,0,0,0,0):
    for j in range(N):
      b=0
      for k in range(10):
        if i[k]==1 and A[j][k]==1:
          b+=1
      a+=B[j][b]
    ans=max(ans,a)
print(ans)