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

max_first, max_second = 0, 0

max_v = -float("inf")
for p in range(1, 1 << 10):
	v = 0
	for n in range(N):
		c = 0
		for m in range(10):
			c += (p & 1 << m != 0) & (F[n][m])
		v += P[n][c]
	max_v = max(max_v, v)

print(max_v)
