object Main extends App {
	import scala.math._

	val N = scala.io.StdIn.readInt

	val F = new Array[Int](N)
	val P = Array.ofDim[Int](N,11)

	for(i<-0 until N){
		val temp = scala.io.StdIn.readLine.split(" ").map(_.toInt)
		for(j<-0 until 10){
			if(temp(j) == 1) F(i) = F(i) | 0x1 << j
		}
	}

	for(i<-0 until N){
		P(i) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	}

	var ans = 0xf0000000
	var sum = 0
	for(i<-1 until (0x1 << 10)){
		sum = 0
		for(j<-0 until N){
			sum = sum + P(j)(ele(i & F(j)))
		}
		ans = max(ans,sum)
//		println(sum)
	}

	println(ans)


	def ele(x: Int): Int = {
		var n = x
		n = (0x55555555 & n) + (0x55555555 & (n >> 1));
		n = (0x33333333 & n) + (0x33333333 & (n >> 2));
		n = (0x0f0f0f0f & n) + (0x0f0f0f0f & (n >> 4));
		n = (0x00ff00ff & n) + (0x00ff00ff & (n >> 8));
		n = (0x0000ffff & n) + (0x0000ffff & (n >> 16));
		n;
	}


	
}
