module Main where

import Data.List

main :: IO ()
main =  putStr . unlines . map (unwords . map show . sort) . unfoldr phi . map (map readInt . words) . lines =<< getContents

phi :: [[Int]] -> Maybe ([Int],[[Int]])
phi [] = Nothing
phi ([0,0]:_) = Nothing
phi (x:xs) = Just (x,xs)

readInt :: String -> Int
readInt = read