import Control.Applicative
import Control.Monad

main :: IO ()
main = do
    ls <- map read . words <$> getLine
    let [n, m, x] = ls

    raw <- replicateM n getLine
    let ulis = map convert (map words raw)

    let ans = successList ulis (take m $ repeat 0) x 0 []
    print $ minimum $ if ans == []
                        then [-1]
                        else ans

convert :: [String] -> (Int, [Int])
convert l = ((read (head l)), (map read (tail l)))

successList :: [(Int, [Int])] -> [Int] -> Int -> Int -> [Int] -> [Int]
successList [] ulis _ cost lis = lis
successList (b:bs) ulis x cost ans = including ++ excluding
        where including = successList bs newlist x (cost + (fst b)) (newsuccesslist newlist)
              excluding = successList bs ulis x cost (newsuccesslist ulis)
              newlist = zipWith (+) (snd b) ulis
              newsuccesslist judging = if all (\y -> x <= y) judging
                  then (cost + (fst b)) : ans
                  else ans