import java.util.Comparator

fun main(args: Array<String>) {
    val N = nextInt()
    val F = Array(N) { listOfInt().map { it == 1 }.toBooleanArray() }
    val P = Array(N) { listOfInt().toIntArray() }
    var ans = Int.MIN_VALUE
    for (b in 1 until (1 shl 10)) {
        var cc = 0
        for (n in 0 until N) {
            var c = 0
            for (m in 0 until 10)
                if (((b shr m) and 1) == 1 && F[n][m]) c += 1
            cc += P[n][c]
//if (c > 0) System.err.println("$b $c")
        }
        if (ans < cc) ans = cc
    }
    println(ans)
}

fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }
fun listOfLong() = listOfString().map(String::toLong)
