import kotlin.math.*

private fun readLn() = readLine()!! // string line
private fun readInt() = readLn().toInt() // single int
private fun readLong() = readLn().toLong() // single long
private fun readStrings() = readLn().split(" ") // list of strings
private fun readInts() = readStrings().map(String::toInt) // list of ints
private fun readLongs() = readStrings().map(String::toLong) // list of longs

fun main() {
    val (n, m, x) = readInts()

    val lines = (1..n).map { readInts() }.toList()

    fun f(sum: List<Int>, lines: List<List<Int>>): Int {
        if (lines.isEmpty()) {
            if (sum.drop(1).all { it >= x }) {
                return sum.first()
            }
            return Int.MAX_VALUE
        }
        val ln = lines.first()
        val nextLines = lines.drop(1)

        // この要素を加算する
        val x = f(sum.zip(ln, Int::plus), nextLines)
        // 加算しない
        val y = f(sum, nextLines)
//        println(x)
//        println(y)
        return min(x, y)
    }

    println(f((0..m).map { 0 }.toList(), lines).takeIf { it != Int.MAX_VALUE } ?: -1)
}
