import Control.Applicative
import Control.Monad

myGCD :: Int -> Int -> Int -> (Int, Int)
myGCD a b c
  | b == 0    = (a, c)
  | otherwise = myGCD b (a `mod` b) (c + 1)


solver :: Int -> Int -> String
solver a b = show x ++ " " ++ show y
  where (x, y) = if a > b then myGCD a b 0 else myGCD b a 0

main :: IO()
main = do
  (a:b:_) <- map (read :: String -> Int) . words <$> getLine
  unless (a == 0 && b == 0) $ do
    putStrLn $ solver a b
    main