import kotlin.collections.List

fun input() = readLine()!!.split(" ")

fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    var F = Array(N, { List(10, { 0 }) })
    for (i in 0..N - 1) {
        F[i] = readLine()!!.split(" ").map { it.toInt() }
    }
    var P = Array(N, { List(11, { 0 }) })
    for (i in 0..N - 1) {
        P[i] = readLine()!!.split(" ").map { it.toInt() }
    }
    var ans = -100000000
    for (i in 1..1023) {
        var cnt = Array(N, { 0 })
        for (j in 0..9) {
            if (i.shr(j) % 2 == 1) {
                // count
                for (n in 0..N - 1) {
                    if (F[n][j] == 1) cnt[n]++
                }
            }
        }
        // profit
        var p = 0
        for (n in 0..N - 1) {
            p += P[n][cnt[n]]
        }
        ans = Math.max(ans, p)
    }
    println(ans)
}
