let input = readLine()!.split(separator: " ").map { Int($0)! }
let N = input[0]
let M = input[1]
let X = input[2]

struct Book {
    var price: Int
    var contents: [Int]
}

var books = [Book]()

for _ in 0 ..< N {
    let book = readLine()!.split(separator: " ").map { Int($0)! }
    books.append(Book(price: book[0], contents: Array(book[1 ... M])))
}

func getBestPrice(_ listToBuy: [Bool] = []) -> Int? {
    guard listToBuy.count < N else {
        if getSumOfComprehension(listToBuy).first(where: { $0 < X }) == nil {
            return getSumOfPrice(listToBuy)
        } else {
            return nil
        }
    }

    switch (getBestPrice(listToBuy + [true]), getBestPrice(listToBuy + [false])) {
    case (.some(let t), .some(let f)):
        return min(t, f)
    case (.some(let t), .none):
        return t
    case (.none, .some(let f)):
        return f
    case (.none, .none):
        return nil
    }
}

func getSumOfPrice(_ listToBuy: [Bool]) -> Int {
    var result = 0
    for i in 0 ..< N {
        guard listToBuy[i] else { continue }
        result += books[i].price
    }
    return result
}

func getSumOfComprehension(_ listToBuy: [Bool]) -> [Int] {
    var result = Array(repeating: 0, count: M)
    for i in 0 ..< N {
        guard listToBuy[i] else { continue }
        for j in 0 ..< M {
            result[j] += books[i].contents[j]
        }
    }
    return result
}

print(getBestPrice() ?? "-1")
