main :: IO ()
main = do ls <- readFile "test.txt"
          putStr (compose ls)

compose :: String -> String
compose = unlines . swapStr . fmap ((\[x,y] -> (x,y)) . take 2 . words) . lines

swapStr :: [(String, String)] -> [String]
swapStr [] = []
swapStr ((m, n):xs) | m == "0" && n == "0" = []
                       | otherwise = (n ++ " " ++ m) : swapStr xs