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

main = do
  [n,m,x] <- map read . words <$> getLine :: IO [Int]
  cas <- replicateM n $ map read . words <$> getLine :: IO [[Int]]
  let ans = solve cas x
  print $ if 1200001 == ans then -1 else ans


powerSetC cas = tail $ do
  chosen <- catMaybes <$> mapM (\n -> [Nothing, Just n]) cas
  return chosen

solve cas x = loop powerSetCAS
  where
    powerSetCAS = powerSetC cas
    loop [] = 1200001
    loop (y:ys) = if boolA then min sumC (loop ys) else loop ys
      where
        sumCA = check y
        sumC = head sumCA
        boolA = foldl (\n m-> (x <= m) && n) True $ tail sumCA

check ca = map sum $ transpose ca
