import Data.Ratio import Data.List main = let f = foldl1'(/).map(toRational.read).words in do [_,a,_,b]<-sequence(replicate 4 getLine) (\[x,y]->let n=x/y in putStrLn(show(numerator n)++" "++show(denominator n)))$map f [a,b]