Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func gcd(x, y int) (int, int) {
	nSteps := 0
	for {
		if x < y {
			tmp := x
			x = y
			y = tmp
		}
		nSteps++
		if x%y == 0 {
			return nSteps, y
		}
		x = x % y
	}
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		a, _ := nextInt()
		b, _ := nextInt()

		if a == 0 && b == 0 {
			break
		}

		nSteps, p := gcd(a, b)
		fmt.Println(p, nSteps)
	}
}

Python: #0197
while True:
    c = 0
    a = 0
    b = 0
    x , y = map(int,input().split())
    if x == y == 0:
        break
    if x < y:
        a = x
        x = y
        y = a
    
    while True:
        b = x%y
        x = y
        y = b
        c += 1
        if y == 0:
            break
    print(x,c)

Python: while True:
    x,y=map(int,input().split())
    if x==0 and y==0:
        break
    count=0
    if y>x:
        x,y=y,x
    while y!=0:
        x=x%y
        x,y=y,x
        count+=1
    print(x,count)

Python: def gcd(a,b):
    c=0
    while b:(a,b),c=(b,a%b),c+1
    print(a,c)
  
while 1:
    m,n=map(int,input().split())
    if m==0:break
    gcd(m,n) if m>n else gcd(n,m)

Python: def euclid_gcd(v1, v2, counter):
  if v2 == 0:
    return (v1, counter)
  else:
    return euclid_gcd(v2, v1 % v2, counter + 1)

while True:
  a, b = map(int, input().split())
  if a == 0:
    break

  a, b = max(a, b), min(a, b)
  print(*euclid_gcd(a, b, 0))

Python: # coding: utf-8
# Your code here!

while True:
    a,b = [int(i) for i in input().split()]
    if a == 0 and b == 0:
        break
    
    if a < b:
        a, b = b, a
    
    c = 0
    while b > 0:
        a, b = b, a % b
        c += 1
    
    print(a, c)

Python: while True:
    n,m=map(int,input().split())
    if n==0 and m==0:
        break
    else:
        if n>=m:
            x,y=n,m
        else:
            x,y=m,n
        s=0
        while True:
            if y!=0:
                x=x%y
                x,y=y,x
                s+=1
            else:
                break
    print(x,s)

Python: while True :
    x, y = map(int, input().split())
    if x == 0 and y == 0 :
        break
    
    ans = 0
    while True :
        if y == 0 :
            break
        if x < y :
            x, y = y, x
        x = x % y
        x, y = y, x
        ans += 1
    
    print(x, ans)

Python: while True:
    X,Y=map(int,input().split())
    if (X,Y)==(0,0):
        break
    if X>=Y:
        pass
    else:
        t=Y
        Y=X
        X=t
    c=0
    while True:
        if Y==0:
            break
        X%=Y
        t=X
        X=Y
        Y=t
        c+=1
    print(X,c)

Python: while 1:
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        break

    x = max(a, b)
    y = min(a, b)

    cnt = 0
    while 1:
        cnt += 1
        tmp = x % y
        x, y = y, tmp
        if tmp == 0:
            break

    print(x, cnt)

Python: def gcd(a, b):
	k = 0
	while b != 0:
		r = a % b
		a, b = b, r
		k += 1
	return [a, k]

while True:
	x, y = list(map(int, input().split()))
	if x == 0: break
	if x < y: x, y = y, x
	ans = gcd(x, y)
	print(*ans)

Python: def gcd(a,b):
    c=0
    while b:(a,b),c=(b,a%b),c+1
    print(a,c)
  
while 1:
    n,m=map(int,input().split())
    if n==0:break
    gcd(n,m) if n>m else gcd(m,n)

Python: while True:
   x,y = map(int, input().split())
   if x==0 and y==0:
      break
   elif x<y:
      X=y
      Y=x
   else:
      X=x
      Y=y
   i = 0
   while True:
      a = X%Y
      X = a
      Z = Y
      Y = X
      X = Z
      i += 1
      if a==0:
         break
   print(X, i)

Python: while True:
    a,b=map(int,input().split())
    if a==0 and b==0:
        break
    if a<b:
        a,b=b,a
    C=0
    while True:
        a=a%b
        a,b=b,a
        C=C+1
        if b==0:
            break
    print(a,C)

Python: while True:
  a,b = map(int,input().split())
  if (a,b) == (0,0):
    break
  x = max(a,b)
  y = min(a,b)
  c = 0
  while y != 0:
    x %= y
    x,y = y,x
    c += 1
  print(x,c)

Python: #入力が2つ0なら処理を終わる
while True:
    a,b = map(int,input().split())
    if a == 0 and b == 0:break

    #2つの数の中で大きい方をa小さい方をbに入れる
    a,b = max(a,b),min(a,b)
    
    #カウンタ変数の初期化
    i = 0
    
    #bが0になったらユークリッドの互除法を終わる
    while True:
        
        #カウンタ変数の更新
        i += 1
        
        #a/bのあまりをaに代入、aとbの値を交換する
        a = a % b
        a,b = b,a
        if b == 0:break
    
    #公約数と回数を出力する
    print(a,i)

Python: while True:
    x, y= map(int, input().split())
    if x==y==0: break
    if x< y: x, y= y, x
    step= 0
    while y> 0:
        x, y, step= y, x%y, step+1
    print(x, step)

Python: while True:
    a,b = map(int,input().split())
    if a==0 and b==0:
        break
    if a<b:
        a,b = b,a
    p=0
    while b != 0:
        c = a % b
        a,b = b,c
        p += 1
    print(a,p)

Python: # coding: utf-8
# Your code here!
while True:
    X,Y=map(int, input().split())
    if X==Y==0:
        break
    
    i=0
    if X<Y:
        X,Y=Y,X
    
    while Y!=0:
        X=X%Y
        X,Y=Y,X
        i+=1
    
    print(X, i)

Python: def gcd(a, b):
  k = 0
  while b != 0:
    r = a % b
    a, b = b, r
    k += 1
  return[a, k]
while True:
  x, y = list(map(int, input().split()))
  if x == 0: break
  if x < y:
    x, y = y, x
  ans = gcd(x, y)
  print(*ans)

Python: while True:
    a,b = [int(i) for i in input().split()]

    if a == 0 and b == 0:
        break

    if a < b:
        a,b = b,a

    cnt = 0
    while b > 0:
        a, b = b, a % b
        cnt += 1

    print(a, cnt)

Python: while True:
    x,y = map(int,input().split())
    if x==0 and y==0: break

    a = max(x,y)
    b = min(x,y)
    p = 0
    while True:
        p += 1
        q = a%b
        a,b = b,q
        if q==0: break
    print(a,p)

Python: while True:
    a,b = [int(i) for i in input().split()]

    if a == 0 and b == 0:
        break

    if a < b:
        a,b = b,a

    cnt = 0
    while b > 0:
        a, b = b, a % b
        cnt += 1

    print(a, cnt)

Python: def gcd(a, b):
	k = 0
	while b != 0:
		r = a % b
		a, b = b, r
		k += 1
	return [a, k]

while True:
	x, y = list(map(int, input().split()))
	if x == 0: break
	if x < y: x, y = y, x
	ans = gcd(x, y)
	print(*ans)

Python: while True:
    n,m=map(int,input().split())
    if n==0 and m==0:
        break
    else:
        if n>=m:
            x,y=n,m
        else:
            x,y=m,n
        s=0
        while True:
            if y!=0:
                x=x%y
                x,y=y,x
                s+=1
            else:
                break
    print(x,s)

Python: def gcd(a,b):
    c=0
    while b:(a,b),c=(b,a%b),c+1
    print(a,c)
 
while 1:
    n,m=map(int,input().split())
    if n==0:break
    gcd(n,m) if n>m else gcd(m,n)

C++: #include <iostream>
using namespace std;
pair<int,int> gcd(int a,int b,int cnt){
	if(b==0)
		return make_pair(a,cnt);
	else{
		return gcd(b,a%b,cnt+1);
	}
}
int main(){
	int n,m;
	while(cin>>n>>m&&!(n==0&&m==0)){
		pair<int,int> p = gcd(n,m,0);
		cout<<p.first<<" "<<p.second<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;

int main(){
  int i=0 ,n ,m ,tmp;
  while( true ){
    cin >> n >> m;
    if( n == 0 && m == 0 ){
      break;
    }
    if( n < m ){ // 降順にする
      tmp = n;
      n = m;
      m = tmp;
    }
    
    while( true ){ // ユークリッドの互除法
      n %= m;
      tmp = n;
      n = m;
      m = tmp;
      i++;
      if( m == 0 ){ // 終わり
	break;
      }
    }
    
    cout << n << " " << i <<   endl;
    i = 0;
  }
}