N = int(input())
F = [0 for i in range(N)]
P = [0 for i in range(N)]
for i in range(N):
  F[i] = [int(x) for x in input().split()]
for i in range(N):
  P[i] = [int(x) for x in input().split()]
ans = 0
for c in range(1, 2 ** 10):
  pat = ('0' * 9 + bin(c)[2:])[-10:]
  ans = max(sum([P[i][sum([F[i][j] * int(pat[j]) for j in range(10)])] for i in range(N)]), ans)
print(ans)