import Control.Monad (replicateM) import Data.List (sortOn) main = do n <- readLn ab <- map (map read . words) <$> replicateM n getLine mapM putStrLn $ solve ab solve :: [[Int]] -> [String] solve ab = reverse $ map (unwords . map show) $ snd $ unzip $ sortOn fst $ zip divab ab where divab = map f ab f [a,b] = realToFrac (a :: Int) / realToFrac (b :: Int) :: Double