fun main() {
    val (n, m, x) = readLine()?.split(" ")?.map(String::toInt) ?: return

    val books = mutableListOf<List<Int>>()
    repeat(n) {
        val book = readLine()?.split(" ")?.map(String::toInt) ?: return
        books.add(book)
    }
    val range = 0.until(n)

    fun gen(remain: List<Int>): List<List<Int>> {
        if (remain.size == 2) {
            return listOf(
                listOf(remain[0]), listOf(remain[1]), remain
            )
        } else {
            val v = remain.first()
            val r = gen(remain.drop(1))
            return mutableListOf(
                listOf(v)
            ).apply {
                addAll(r.map {
                    listOf(v) + it
                })
                addAll(r)
            }
        }
    }

    val list = if (n >= 2) {
        gen(range.toList())
    } else {
        listOf(listOf(0))
    }
    list.mapNotNull { candidate ->
        val t = Array(m) { 0 }
        var tp = 0L
        candidate.forEach {
            val book = books[it]
            tp += book[0]
            1.until(m + 1).forEach {
                t[it - 1] += book[it]
            }
        }
        if (t.all { it >= x }) {
            tp
        } else {
            null
        }
    }.min()?.let {
        println(it.toString())
        return
    }
    println("-1")
}