import qualified Data.ByteString.Char8 as B
import Data.Maybe
import Data.List

main = do
  getLine
  ass <- map (map (fst . fromJust . B.readInt) . B.words) . B.lines <$> B.getContents
  print (sports maxBound ass)

sports :: Int -> [[Int]] -> Int
sports r ass
  | any null ass' = min r nx
  | otherwise = sports (min r nx) ass'
  where
    ass' = map (\yys@(y:ys) -> if y==x then ys else yys) ass
    (nx,x) = last . sort . map (\xs -> (length xs, head xs)) . group . sort . map head $ ass