data IRect = IRect Int Int deriving Eq

instance Ord IRect where
 (<=)  (IRect h1 w1) (IRect h2 w2) = h1^2+w1^2 < h2^2+w2^2 || (h1^2+w1^2 == h2^2+w2^2 && h1<=h2)

instance Show IRect where
 show (IRect h w) = show h ++ " " ++ show w 

main = interact $ unlines . map (show . integral_rectangles . map read . words) . init . lines

integral_rectangles [h,w] = minimum [IRect h' w'| h'<-[1..150], w'<-[1..150], h'<w', IRect h' w' > IRect h w]