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

ans = -(1<<60)
for bit in range(1, 1<<10): # 2**10
  tmp = 0
  for i in range(N):
    cnt = 0
    for j in range(10):
      if (bit>>j)&1 and F[i][j]:
        cnt += 1
    tmp += P[i][cnt]
  
  if ans<tmp:
    ans = tmp
print(ans)
    