q?d=(q`div`d)*d;u=getLine;main=u>>fmap(map read.words)u>>=putStrLn.maybe"-1"h.foldr(\s->(>>=i s))(Just(2,2));h(a,b)=show a++" "++show b;i d(a,b)=if-l>u then Nothing else Just(-l,u+d-1)where l=(-a)?d;u=b?d