fun main() {
    val (n, m, x) = readLine()!!.split(" ").map {it.toInt()}
    val books = Array<Book>(n) { Book(0, emptyList())}
    for (i in 0 until n) {
        val list = readLine()!!.split(" ").map { it.toInt() }
        books[i] = Book(list[0], list.subList(1, list.size))
    }

    val plans = Array(2 shl n) { IntArray(m) to 0 }
    for (i in plans.indices) {
        var cost = 0
        for (k in 0 until n) {
            if (i and (1 shl k) != 0) {
                for (l in 0 until m) {
                    plans[i].first[l] += books[k].a[l]
                }
                cost += books[k].c
            }
        }
        plans[i] = plans[i].first to cost
    }

    var min = Int.MAX_VALUE
    for (plan in plans) {
        if (plan.first.all { it >= x }) {
            min = kotlin.math.min(min, plan.second)
        }
    }

    if (min == Int.MAX_VALUE) {
        println(-1)
    } else {
        println(min)
    }
}

data class Book(val c: Int, val a: List<Int>)
