import Control.Monad

main :: IO ()
main = do
  mn <- getLine
  if mn == "0 0"
    then return ()
    else do
      let ls = map read $ words mn
      putStrLn $ solve ls
      main

solve :: [Int] -> String
solve [m,n] = toStr (gojohou ((max m n),(min m n),0))
  where
    gojohou :: (Int,Int,Int) -> (Int,Int,Int)
    gojohou (ma,mi,c)
      | r == 0 = (mi,r,c+1)
      | otherwise = gojohou (mi,r,c+1)
      where
        r = ma `mod` mi
    toStr :: (Int,Int,Int) -> String
    toStr (i,_,c) = (show i) ++ " " ++ (show c)