import Data.List

main = do
  li <- getLine
  let [n,m,x] = map read $ words li
  co <- getContents
  let cass = map (map read . words) $ lines co
  let ans = compute n m x cass
  print ans

compute :: Int -> Int -> Int -> [[Int]] -> Int
compute n m x cass
  | null sucs = -1
  | True      = head (head sucs)
  where
    sucs = filter success $ sort $ foldl step [repeat 0] cass
    step acc cas = acc ++ map (zipWith (+) cas) acc
    success (c:as) = all (x <=) as