import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- readLn :: IO Int
  if n == 0
    then return ()
    else do
    ns <- replicateM n
          (map read . words <$> getLine) :: IO [[Int]]
    let mins = map minimum ns
        maxs = map maximum (transpose ns)
        anss = filter ((== 2) . length) $
               group (sort (mins ++ maxs))
    print $ if null anss then 0 else head (head anss)
    main