import Data.Word

main :: IO ()
main = do
  c <- getContents
  putStrLn . init . unlines . map swap $ init . lines $ c 
                                                   
swap :: String -> String
swap xs = if (read $ first xs :: Int) < (read $ second xs :: Int)
                   then first xs ++ " " ++ second xs
                   else second xs ++ " " ++ first xs
                 
first :: String -> String
first wd = head $ words wd

second :: String -> String
second wd = last $ words wd

