import Control.Monad

inf = 10000000

int2bin :: Int -> Int -> [Int]
int2bin 0 _ = []
int2bin n a = mod a 2 : int2bin (n-1) (a `div` 2)

listAdd :: [Int] -> [Int] -> [Int]
listAdd [] _ = []
listAdd _ [] = []
listAdd (x:xs) (y:ys) = x+y : listAdd xs ys

allListAdd :: [[Int]] -> [Int] -> [Int]
allListAdd [] _ = [0,0..]
allListAdd (x:xs) (b:bs) = listAdd (allListAdd xs bs) $ if b == 0 then take (length x) [0,0..] else x

solve :: Int -> Int -> Int -> [[Int]] -> [[Int]] -> Int
solve n m x a [] = inf
solve n m x a (b:bs) = do
    let sum_list = allListAdd a b
    let tmpans = if length (filter (\ys -> ys < x) $ tail sum_list) == 0
                    then head sum_list
                    else inf
    min tmpans $ solve n m x a bs

main = do
    l <- getLine
    let (n:m:x:_) = map read (words l) :: [Int]
    aa <- replicateM n getLine
    let a = map (map read) $ map words aa :: [[Int]]
    let border = subtract 1 $ product $ take n [2,2..]
    let comBin = map (int2bin n) [1..border]
    let ans = solve n m x a comBin
    print $ if ans == inf
               then -1
               else ans


