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

    searchAllPatterns(2, n.toInt()) { b ->
        val filtered = books.filterIndexed { index, _ -> b[index] == 1L }

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

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

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

    println(answer)
}

@Suppress("SameParameterValue")
private inline fun searchAllPatterns(numberOfChoices: Int, length: Int, action: (LongArray) -> Unit) {
    val patterns = (1..length).fold(1L) { acc: Long, _: Int -> acc * numberOfChoices }
    for (i in 0 until patterns) {
        val array = LongArray(length)
        var div = 1
        for (j in 0 until length) {
            array[length - j - 1] = (i / div) % numberOfChoices
            div *= numberOfChoices
        }
        action(array)
    }
}
