import           Data.Maybe
import           Data.Int
import           Data.List
import           Data.Char
  -- import qualified Data.Vector.Unboxing as VU
import qualified Data.Vector as V
import qualified Data.Vector.Mutable as VM
import qualified Data.Vector.Unboxed as VU
import qualified Data.Vector.Unboxed.Mutable as VUM
import qualified Data.ByteString.Char8 as BS
import           Data.List (scanl')
import           Data.IORef
import           Control.Monad
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Control.Applicative

readInt = BS.readInt . BS.dropWhile isSpace
getVector f = VU.unfoldr f <$> BS.getLine
getIntVector = getVector readInt
getBSVector = getVector BS.uncons

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 120001 == 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 [] = 120001
    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

test = [[60,2,2,4],[70,8,7,9],[50,2,3,9]]

check ca = map sum $ transpose ca
