import Data.List
import Control.Monad

main :: IO ()
main = do
    [n, _m, x] <- map read . words <$> getLine
    ca <- replicateM n $ do
        (c: as) <- map read . words <$> getLine
        return (c, as)

    let ans = foldl min maxBound $ do
        sel <- replicateM n [False, True]
        let (cs, as) = unzip [ t | (b, t) <- zip sel ca, b]
        guard $ not $ null as
        guard $ all (>= x) $ map sum $ transpose as
        return $ sum cs

    print (if ans == maxBound then -1 else ans :: Int)
