m@main=getLine>>=putStrLn.f.reads>>m f[(a,s:b)]|x<-read b,d<-show.div(lcm a x)=d x++s:d a