def main():
	n = int(input())
	f = []
	for i in range(n):
		f.append(list(map(int,input().split())))
	p = []
	for i in range(n):
		p.append(list(map(int,input().split())))
	ans = -2147483648
	for x10 in range(1,2**10-1):
		x2 = base_10_to_n(x10,2)
		for _ in range(10-len(x2)):	
			x2 = '0' + x2
		benefit = 0
		for j in range(n):
			count = 0
			for k in range(10):
				if(f[j][k] == 1 and x2[k] == '1'):
					count+=f[j][k]
			benefit+=p[j][count]
		if(ans<benefit): ans = benefit
	print(ans)

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

main()