module Main where

import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Control.Monad
import Data.List
import Data.Ord

powerset :: [a] -> [[a]]
powerset = filterM (const [True, False])

conv::[[Int]]->[Int]
conv [] = []
conv (x:[]) = x
conv (x:xx:[]) = zipWith (+) x xx
conv (x:xx:xs) = conv ((zipWith (+) x xx):xs)

main :: IO ()
main = do
    [n,m,x] <- map (fst.fromJust.BS.readInt).BS.words <$> BS.getLine
    as <- replicateM n $ map (fst.fromJust.BS.readInt).BS.words <$> BS.getLine :: IO[[Int]]
    -- let n = 3
    -- let m = 3
    -- let x = 10
    -- let as = [[60,2,2,4],[70,8,7,9],[50,2,3,9]]
    -- let ac = powerset as
    let result = sort $ map head $ filter ( \e -> all ( \t -> t >= x ) e && not (null e)) $ map conv (powerset as)
    putStr $ if null result then "-1" else show (head result)