import numpy as np

n = int(input())
f = np.array([list(map(int, input().split())) for i in range(n)])
p = np.array([list(map(int, input().split())) for i in range(n)])

ans = -99

openptn=np.array([[int(s) for s in list('{0:010b}'.format(i))] for i in range(1,2**10)])

for i in range(2**10 - 1):
	subans = 0
	for j in range(n):
		count = sum(f[j]*openptn[i])
		subans +=p[j][count-1]
		#print(subans)
	ans = max(ans, subans)

print(ans)