open System

let n, m, x =
    let l = Console.ReadLine().Split(' ') |> Array.map int
    l.[0], l.[1], l.[2]

let lines =
    [ for i in 0 .. n - 1 do
        yield Console.ReadLine().Split(' ') |> Array.map int ]

let a = Array2D.init n m (fun i j -> lines.[i].[j + 1])
let c = Array.init n (fun i -> lines.[i].[0])

let ans =
    let mutable ans = Int32.MaxValue

    let rec dfs is k =
        if k = n then
            let ok =
                [ for j in 0 .. m - 1 do
                    let mutable sum = 0
                    for i in is do
                        sum <- sum + a.[i, j]
                    yield sum ]
                |> List.forall (fun sum -> sum >= x)

            if ok then
                let cost =
                    let mutable sum = 0
                    for i in is do
                        sum <- sum + c.[i]
                    sum
                ans <- min ans cost
        else
            dfs is (k + 1)
            dfs (k :: is) (k + 1)

    dfs [] 0
    if ans = Int32.MaxValue then ans <- -1
    ans

ans |> Console.WriteLine
