main :: IO ()
main = interact $ solve . map (read :: String -> Int). words

solve = unlines . map (\(x, y) -> show x ++ " " ++ show y) . reverse . tail . reverse . map myReplace . myZip

myZip :: [Int] -> [(Int, Int)]
myZip [] = []
myZip (a:b:xs) = (a, b) : myZip xs

myReplace :: Ord a => (a, a) -> (a, a)
myReplace (x, y)
	| x < y     = (x, y)
	| otherwise = (y, x)
