object Main extends App{
    val Array(n,m,x) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
    val ca = for(count <- 1 to n) yield scala.io.StdIn.readLine.split(" ").map(_.toInt)
    val c = ca.map(_(0))
    val a = ca.map(_.drop(1))
    val total_rikaido = for(count1 <- 0 until m) yield a.map(_(count1)).sum 
    if(total_rikaido.forall(x<=_)){
        val simple_case = ca.filter(e1 => e1.drop(1).forall(x <= _)).map(_(0))
        val ca_combinations = (2 to n).map(ca.combinations(_).toArray).toArray
        val combinations_processed = for(count <- ca_combinations) yield {
            //count.reduce(array_add(_, _))
        }
        
        val success_money = simple_case ++: combinations_processed.map(_(0))
        //println(success_money.min)
    }
    else println(-1)
    
    def array_add(arr1: Array[Int], arr2: Array[Int]): Array[Int] = {
        (for(count <- 0 until m+1) yield arr1(0) + arr2(0)).toArray
    }
}
