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) ]
J = [0 for i in range(10)]
Ben = - (10**8)

for n in range(1,2**10):
  J = list(format(n, 'b'))
  b=0
  for k in range(N):
    c=0
    for ij in range(len(J)):
      if J[ij]=="1" and F[k][ij]==1:
        c+=1
    b += P[k][c]
  if b>Ben:
    Ben=b

print(Ben)