import numpy as np

n = int(input())
f = np.zeros((n, 10), dtype=np.int64)
p = np.zeros((n, 11), dtype=np.int64)

for i in range(n):
  tmp = list(map(int, input().split()))
  for j in range(10):
      f[i][j] = tmp[j]
for i in range(n):
  tmp = list(map(int, input().split()))
  for j in range(11):
    p[i][j] = tmp[j]

r = -1e18
for b in range(1, 1<<10):
  s = 0
  for i in range(n):
    c = 0
    for j in range(10):
      if (b >> j) & 1 == 1 and f[i][j]:
        c += 1
    s += p[i][c]
  if r < s:
    r = s

print(r)
