N = int(input())
F = []
P = []
maxl = 0
for i in range(N):
  L = list(map(int,input().split()))
  F.append(L)
for i in range(N):
  L = list(map(int,input().split()))
  maxl = min(maxl,min(L))
  P.append(L)
k=1
K = [0,0,0,0,0,0,0,0,0,0]
while k<1024:
  maxll=0
  d = k
  for i in range(10):
    K[i] = d%2
    d = d//2
  k+=1
  for Ni in range(N):
    count=0
    for i in range(10):
      if F[Ni][i] and K[i]:
        count+=1
    maxll+=P[Ni][count]
  maxl = max(maxll,maxl)
print(maxl)