from itertools import product
N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

# 全て試す。
li = list(product([0, 1], repeat=10))

ans = - 10 ** 19
for i in li:
  cnt = 0
  for f, p in zip(F, P):
    opendays = sum([a * b for a, b in zip(i, f)])
    cnt += p[opendays]
  ans = max(ans, cnt)
print(ans)