n = int(input())
f = []
for i in range(n):
	ff = list(map(int, input().split()))
	f.append(ff)
p = []
for i in range(n):
	pp = list(map(int, input().split()))
	p.append(pp)
ans = -10**10
for i in range(1, 2**10):
	tmp = 0
	for j in range(n):
		c = 0
		for k in range(10):
			if (i >> k) & 1 and f[j][k] == 1:
				c += 1
		tmp += p[j][c]
	ans = max(ans, tmp)
print (ans)
