import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    val n = input.split(LINE_SEPARATOR).head.split(" ").head.toInt
    val m = input.split(LINE_SEPARATOR).head.split(" ").tail.head.toInt
    val x = input.split(LINE_SEPARATOR).head.split(" ").tail.tail.head.toInt
    val c = input.split(LINE_SEPARATOR).tail.map(_.split(" ").head.toInt)
    val a = input.split(LINE_SEPARATOR).tail.map(_.split(" ").tail.map(_.toInt))

    val resList = (1 to 1<<n).toVector.map{bit =>
      if ((0 until m).map{j =>
        (0 until n).foldLeft(0){(sum, i) =>
          if ((1 & bit >> i) == 1) sum + a(i)(j) else sum
        }
      }.forall(_ >= x)) Some((0 until n).filter{i => (1 & bit >> i)==1}.foldLeft(0){_ + c(_)}) else None
    }

    (if (resList.exists(_.isDefined)) resList.filter(_.isDefined).map(_.get).min else -1).toString
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """3 3 10
      |60 2 2 4
      |70 8 7 9
      |50 2 3 9""".stripMargin -> """120
                                        |
                                   |
                                |""".stripMargin,
    """3 3 10
      |100 3 1 4
      |100 1 5 9
      |100 2 6 5""".stripMargin -> """-1
                                         |
                               |""".stripMargin,
    """8 5 22
      |100 3 7 5 3 1
      |164 4 5 2 7 8
      |334 7 2 7 2 9
      |234 4 7 2 8 2
      |541 5 4 3 3 6
      |235 4 8 6 9 7
      |394 3 6 1 6 2
      |872 8 4 3 7 2""".stripMargin -> """1067"""
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

Measured memory_bytes: 58000