n = int(input())
f_matrix = [[0]*10]*n
p_matrix = [[0]*11]*n
f_matrix = [[int(i) for i in input().split()] for _ in range(n)]
p_matrix = [[int(i) for i in input().split()] for _ in range(n)]

ans = -10**6
for i in range(1, 2**10):
  
  for j in range(n):
    c = 0
    tmp = 0
    for k in range(10):
      if i>>k & 1 and f_matrix[j][k] is 1:
        c += 1
    tmp += p_matrix[j][c]
  ans = max(ans, tmp)
print(ans)