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

data class Book(val c: Int, val a: List<Int>)

fun main(args: Array<String>) {
  val (n, m, x) = readLine()!!.split(' ').map(String::toInt)
  val books = Array(n) {
    val ca = readLine()!!.split(' ').map(String::toInt)
    Book(ca[0], ca.drop(1))
  }
  var ans = Int.MAX_VALUE
  repeat(2.0.pow(n).toInt()) { b ->
    var c = 0
    val sum = IntArray(m)
    for (i in 0 until n) {
      if (b and (1 shl i) == 0) continue
      c += books[i].c
      books[i].a.forEachIndexed { j, a -> sum[j] += a }
    }
    if (sum.all { x <= it }) {
      ans = min(ans, c)
    }
  }
  println(if (ans == Int.MAX_VALUE) -1 else ans)
}
