
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord
import Data.Maybe
import qualified Data.Set as S
import Data.Graph
import qualified Data.IntMap.Strict as IM 

r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine


main :: IO ()
main = do
    [n,m,x] <- r'
    books <- replicateM n $ do
        c:as <- r'
        return (c, as)
    --print books
    let takeVec = forM [1..n] (\_->[0,1])
    let r = minimum $ map (testAll x books) takeVec
    print $ if r > 10^8 then -1 else r

testAll :: Int -> [(Int,[Int])] -> [Int] -> Int
testAll x book tkv = let filtered = map snd $ filter ((==1).fst) $ zip tkv book in
    if test x filtered then sum $ map fst filtered else maxBound


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


