import java.util.*

fun main() = abc167c()

@OptIn(ExperimentalStdlibApi::class)
fun abc167c() {
    val (n, m, x) = readLine()!!.split(' ').map { it.toLong() }
    val books = (1..n).map {
        val map = readLine()!!.split(' ').map { it.toLong() }
        map[0] to map.drop(1)
    }

    var answer = Long.MAX_VALUE

    for (i in 0L until (1L shl n.toInt())) {
        val bitSet = BitSet.valueOf(longArrayOf(i))
        val filtered = books.filterIndexed { index, pair -> bitSet[index] }

        val sum = LongArray(m.toInt())
        filtered.forEach { it.second.forEachIndexed { index, l -> sum[index] += l } }

        if (sum.all { it >= x }) {
            answer = Math.min(answer, filtered.map { it.first }.sum())
        }
    }

    if (answer == Long.MAX_VALUE) answer = -1

    println(answer)
}

