import Control.Applicative import Control.Monad import Data.List main :: IO () main = do n <- readLn solve <$> replicateM n f >>= mapM_ (putStrLn . unwords . map show) where f = map read <$> words <$> getLine solve :: [[Int]] -> [[Int]] solve = sortBy f where f [a1, b1] [a2, b2] | a1 * b2 > a2 * b1 = LT | a1 * b2 < a2 * b1 = GT | otherwise = EQ