N = input()
F = [map(int, raw_input().split()) for _ in range(N)]
P = [map(int, raw_input().split()) for _ in range(N)]
res = -float('inf')
for i in range(1, 2 ** 10):
  mask = '0' * (10 - len(bin(i)) + 2) + bin(i)[2:]
  cand = 0
  for j in range(N):
    c = 0
    for k in range(10):
      c += F[j][k] & int(mask[k])
    cand += P[j][c]
  res = max(res, cand)
print res