import Control.Monad
import Data.Array
import Data.List
import Data.Maybe

data RefBook = RefBook Int (Array Int Int)

readInts :: IO [Int]
readInts = map read . words <$> getLine

readRefBook :: Int -> IO RefBook
readRefBook m = do
  (c:as) <- readInts
  return $ RefBook c (listArray (1, m) as)

main :: IO ()
main = do
  [n, m, x] <- readInts
  as <- replicateM n $ readRefBook m
  print $ fromMaybe (-1) $ solve m x as

solve :: Int -> Int -> [RefBook] -> Maybe Int
solve m x = foldr f Nothing . map (calc m x) . subsequences
  where
    f Nothing  Nothing  = Nothing
    f (Just x) Nothing  = Just x
    f Nothing  (Just y) = Just y
    f (Just x) (Just y) = Just $ x `min` y


calc :: Int -> Int -> [RefBook] -> Maybe Int
calc m x rbs = if reach then Just cost else Nothing
  where
    reach = and [ sum [ rb ! i | RefBook _ rb <- rbs ] >= x | i <- [1 .. m] ]
    cost  = sum [ c | RefBook c _ <- rbs ]
