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 (b in bits(2, n.toInt())) {
        val filtered = books.filterIndexed { index, _ -> b[index] == 1 }

        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)
}

private fun pow(n: Long, p: Long): Long {
    var x = n
    var y = p
    var result = 1L
    while (y > 0) {
        if (y % 2 == 1L)
            result = (result * x)
        y = y shr 1
        x = (x * x)
    }
    return result
}

private fun bits(pattern: Int, length: Int): Array<IntArray> {
    val patterns = pow(pattern.toLong(), length.toLong()).toInt()
    val array = Array(patterns) { IntArray(length) }
    for (i in 0 until patterns) for (j in 0 until length) {
        array[i][length - j - 1] = (i / pow(pattern.toLong(), j.toLong()) % pattern).toInt()
    }
    return array
}
