object Main extends App {
  import java.util.Scanner
  val sc = new Scanner(System.in)
  val n = sc.nextInt()
  val m = sc.nextInt()
  val x = sc.nextInt()

  val ca = (1 to n).map { _ =>
    val c = sc.nextInt()
    val a = (1 to m).map { _ =>
      sc.nextInt()
    }
    (c, a)
  }

  def limit(aa: IndexedSeq[(Int, Seq[Int])]): Int = {
    val t = aa.foldLeft((0, Seq.fill(m)(0), false)) { (acc, cai) =>
      if (acc._3) {
        acc
      } else {
        val i = acc._1 + cai._1
        val j = acc._2.zip(cai._2).map(t => t._1 + t._2)
        val k = j.forall(_ >= x)
        (i, j, k)
      }
    }
    if (t._3) t._1 else -1
  }
  val r = ca.permutations.map(limit).filter(_ >= 0)
  if (r.isEmpty) {
    println(-1)
  } else {
    println(r.min)
  }
}
