import java.util.*

fun main(args : Array<String>) {
    val (n, m, x) = readLine()!!.split(" ").map { it.toInt() }
    val books = Array(n) {
        val ca = readLine()!!.split(" ").map { it.toInt() }
        Pair(ca[0], ca.drop(1))
    }

    val bfs = ArrayDeque<MutableList<Int>>()
    bfs.addLast(mutableListOf(0))
    bfs.addLast(mutableListOf(1))

    var minPrice = Int.MAX_VALUE

    while (bfs.isNotEmpty()) {
        val list = bfs.removeFirst()

        if (list.size == n) {
            var mm = IntArray(m) {0}
            var price = 0

            list.forEachIndexed { idx, b ->
                if (b == 1) {
                    price += books[idx].first
                    for (i in 0 until m) {
                        mm[i] += books[idx].second[i]
                    }
                }
            }
            if (mm.all { it >= x }) {
                minPrice = Math.min(minPrice, price)
            }
            continue
        }

        val cp0 = mutableListOf<Int>()
        cp0.addAll(list)
        cp0.add(0)
        bfs.addLast(cp0)

        val cp1 = mutableListOf<Int>()
        cp1.addAll(list)
        cp1.add(1)
        bfs.addLast(cp1)
    }

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