import Foundation

func check(t: [[Int]], d: [Bool], x: Int) -> Bool {
  var rst = [Int](repeating: 0, count: t[0].count)
  for i in 0..<t.count {
    if !d[i] { continue }
    for j in 0..<t[i].count {
      rst[j] += t[i][j]
    }
  }
  let ans = rst.contains { x > $0 }
  return !ans
}

func calc(c: [Int], d: [Bool]) -> Int {
  return c.enumerated().reduce(0) { (a, e) in
    return d[e.0] ? a + c[e.0] : a
  }
}

if let s = readLine() {
  let ss = s.split(separator: " ").map { Int($0)! }
  let n = ss[0] // 参考書数
  let m = ss[1] // アルゴリズム数
  let x = ss[2] // 目標理解度
  var c = [Int](repeating: 0, count: n)
  var a = [[Int]](repeating: [Int](repeating: 0, count: m), count: n)
  for i in 0..<n {
    if let aa = readLine() {
      let t = aa.split(separator: " ").map { Int($0)! }
      c[i] = t[0]
      for j in 1..<m+1 {
        a[i][j-1] = t[j]
      }
    }
  }
  
  let max: Int = Int(truncating: NSDecimalNumber(decimal: pow(2, n)))
  var ans: [Int] = []
  for i in 0..<max {
    var b = String(i, radix: 2)
    for _ in 0..<n-b.count {
      b = "0" + b
    }
    let d = b.enumerated().map { $1 == "1" }
    if check(t: a, d: d, x: x) {
      ans.append(calc(c: c, d: d))
    }
  }
  
  if let min = ans.min() {
    print(min)
  } else {
    print(-1)
  }
}
