import java.util.*
import kotlin.math.min

fun main() = abc167c()

@OptIn(ExperimentalStdlibApi::class)
fun abc167c() {
    data class Book(val price: Long, val exp: List<Long>)

    val (n, m, x) = readLine()!!.split(' ').map { it.toLong() }
    val books = (1..n).map {
        val line = readLine()!!.split(' ').map { it.toLong() }
        Book(line[0], line.drop(1))
    }

    var answer = Long.MAX_VALUE
    val patterns = arrayOf(true, false)

    dfs(n.toInt(), patterns) { pattern ->
        val filtered = books.filterIndexed { index, _ -> pattern[index] }

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

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

    println(answer.takeIf { it < Long.MAX_VALUE } ?: -1)
}

@OptIn(ExperimentalStdlibApi::class)
private fun <T> dfs(
    length: Int,
    patterns: Array<T>,
    list: MutableList<T> = mutableListOf(),
    operation: (List<T>) -> Unit
) {
    if (list.size == length) return operation(list)

    patterns.forEach {
        list.add(it)
        dfs(length, patterns, list, operation)
        list.removeLast()
    }
}
