func backtrack(_ price: Int, _ points: [Int], _ remained: Int, 
               _ bookIndex: Int, _ prices: [Int], _ bookPoints: [[Int]]) -> Int {
	if remained == 0 {
      return price
    }
  	if bookIndex == prices.count {
    	return Int.max
    }
	
 	let notPick = backtrack(price, points, remained, bookIndex + 1, prices, bookPoints)
  	let nextPrice = price + prices[bookIndex]
  	var remained = remained
  	var points = points
  	for i in 0..<bookPoints[bookIndex].count {
      	let prev = points[i]
  		points[i] -= bookPoints[bookIndex][i]
      	if prev > 0 && points[i] <= 0 {
          remained -= 1
        }
    }
  	let pick = backtrack(nextPrice, points, remained, bookIndex + 1, prices, bookPoints)
  	return min(pick, notPick)
}


let first = readLine()!.split(separator: " ")
let N = Int(first[0])!
let M = Int(first[1])!
let X = Int(first[2])!
var prices: [Int] = .init(repeating: -1, count: N)
var points: [Int] = .init(repeating: X, count: M)
var bookPoints: [[Int]] = .init(repeating: .init(repeating: 0, count: M), count: N)
for i in 0..<N {
  let line = readLine()!.split(separator: " ")
  prices[i] = Int(line[0])!
  for j in 0..<M {
    bookPoints[i][j] = Int(line[j + 1])!
  }
}
let res = backtrack(0, points, M, 0, prices, bookPoints)
print(res == .max ? -1 : res)
