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)]
ans = -(10**9)
for i in range(1,2**10):
  S = [0]*N
  tmp = 0
  for j in range(10):
    for k in range(N):
      if (i >> j) & 1 and F[k][j] == 1:
        S[k] += 1
  for m in range(N):
    tmp += P[m][S[m]]
  ans = max(ans,tmp)
print(ans)