-- {-# LANGUAGE TypeApplications #-}
-- {-# LANGUAGE BlockArguments #-}
import Control.Monad
import Data.Maybe
import Data.Char (isSpace)
import Data.List (unfoldr)
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS

tuplify2 (x:y:_) = (x,y)
tuplify2 _ = undefined

--Input functions with ByteString
readInt = fst . fromJust . BS.readInt
readIntTuple = tuplify2 . map readInt . BS.words
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntN n = map readInt <$> replicateM (fromIntegral n) BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents


main = do
  [n,m,x] <- getIntList
  books  <- replicateM n $ do
    c:as <-getIntList
    return (c,as)
  let allPatterns = replicateM n [True,False]
  let result = minimum $ map (filterSum x books) allPatterns
  print $ if (result == maxBound) then -1 else result

filterSum :: Int -> [(Int,[Int])] -> [Bool] -> Int
filterSum x books pattern =
  if (test x filteredBooks) then sum $ map fst filteredBooks else maxBound
    where filteredBooks = map snd $ filter (fst) $ zip pattern books

test  :: Int -> [(Int,[Int])] -> Bool
test x books = all (>= x) $ foldl (zipWith (+)) [0,0..] $ map snd books