import Control.Monad
import Data.List
import Data.Function

main :: IO ()
main = do
  l1 <- getLine
  let [n, m, x] = map read $ words l1 :: [Int]
  ln <- replicateM n getLine
  let ca = map (map read . words) ln :: [[Int]]
      asum = foldl (zipWith (+)) (repeat 0) $ map tail ca
      achieved = all (>=x) asum
  print $ if achieved then f n m x ca
    else -1

f n m x ca = head $ minimumBy (compare `on` head) pass
  where
    patterns = subsequences [0..n-1]
    calc = map (foldl (\acc i -> zipWith (+) acc $ ca !! i) (replicate (m + 1) 0)) patterns
    pass = filter (all (>=x) . tail) calc