N = input()
F = [map(int, raw_input().split()) for _ in range(N)]
P = [map(int, raw_input().split()) for _ in range(N)]
ans = -10**100
for b in range(1,2**10):
  a = 0
  for i in range(N):
    c = 0
    for j in range(10):
      c += int(b>>j&1 and F[i][j])
    a += P[i][c]
  ans = max(ans, a)
print ans
