import scala.io.StdIn

object Main extends App {

  val n = StdIn.readInt
  val f = Iterator.continually(StdIn.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .toArray
  val p = Iterator.continually(StdIn.readLine)
    .take(n)
    .map(_.split(" ").map(_.toInt))
    .toArray

  var ans = Int.MinValue

  for(key <- 1 until 1 << 10) {
    var score = 0
    for(i <- 0 until n) {
      var d = 0
      for(j <- 0 until 10) {
        if(((key>>j & 1) & f(i)(j)) == 1) d += 1
      }
      score += p(i)(d)
    }
    if(ans < score) ans = score
  }
  
  println(ans)
}