import Data.List main = do n <- readLn :: IO Int getLine pqs <- map (map read . words) . lines <$> getContents print $ foldl (\x pq -> if elem x pq then head (delete x pq) else x) n pqs