n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]
mise = []

for i in range(2 ** 10):
	kari = []
	ii = i
	for j in range(10):
		kari.append(ii%2)
		ii = ii//2
	mise.append(kari)
	
mise.pop(0)

ans = -100000000
counter = 0
rieki = 0

for i in range(len(mise)):
	for j in range(len(f)):
		for k in range(10):
			if mise[i][k] == 1 and f[j][k] == 1:
				counter += 1
		rieki += p[j][counter]
		counter = 0
	ans = max(ans,rieki)
	rieki = 0

print(ans)
