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)
	}
}

C++: #include <iostream>
using namespace std;
int main(void){
	for (int i = 0; i < 1000; i++){
		int a,b;

		cin >> a >> b;

		if (a == 0 && b == 0)
			break;

		int j,r,COUNT = 1;

		if (b > a){
			j = a;
			a = b;
			b = j;
		}

		while((r = a % b) != 0)
			{ a = b; b = r; COUNT++;}

		cout << b << " " <<COUNT << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int x,y,mem;
  while(cin>>x>>y){
    if(x==0&&y==0) break;
    int count=0;
    if(y>x){
      mem = x;
      x = y;
      y = mem;
    }
    while(y!=0){
      x %= y;
      mem = x;
      x = y;
      y = mem;
      count++;
      //cout << y << endl;
    }
    cout << x << ' ' << count << endl;
  }
  return 0;
}

C++: #include <cstdio>
using namespace std;

void greatestCommonDivisor(int x, int y);

int main(){
	int a, b;
	while(scanf("%d %d", &a, &b)){
		if(a == 0 and b == 0) break;
		greatestCommonDivisor(a, b);
	}
	return 0;
}

void greatestCommonDivisor(int x, int y){
	int temp, count = 0;
	while(true){
		x %= y;
		if(x == 0) break;
		temp = x;
		x = y;
		y = temp;
		count++;
	}
	printf("%d %d\n", y, count + 1);
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){

  int x,y,x1,y1;
  int cnt=0;

  while(1)
    {
      cnt=0;
      cin >> x >> y;

      if(x==0 && y==0)
	{
	  break;
	}

      if(x < y)swap(x,y);

      while(1)
	{
	  x = x%y;
	  swap(x,y);
	  
	  cnt++;
	  if(y == 0)break;
	}
	
      cout << x << " " << cnt << endl;
    }
}

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

int euclid(int a, int b) {
	int cnt = 0;
	while (a != 0 && b != 0) {
		if (a >= b) { a = a%b; }
		else { b = b%a; }
		cnt++;
	}
	return cnt;
}

int main() {
	int x, y;
	while (true) {
		cin >> x >> y;
		if (x + y == 0) { break; }
		cout << __gcd(x, y) << ' ' << euclid(x, y) << endl;
	}
}

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    ll a,b;
    while(cin>>a>>b){
        if(a==0 && b==0)break;
        ll count=0;
        while(b!=0){
            ll box=b;
            b=a%b;
            a=box;
            count++;
        }
        cout<<a<<" "<<count<<endl;
    }
    return 0;
}

C++: #include <stdio.h>
int main(){
  long x,y,a,counter=0;

  while(1){
    scanf("%ld %ld0",&x,&y);
    if(x==y==0)break;
    while(1){
      counter++;
      a=x%y;
      if(a==0)break;
      x=y;
      y=a;
    }
    printf("%ld %ld\n",y,counter);
    counter=0;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
int cnt;

int gcd(int w,int m){
  if ( m ==0)return w;
  cnt++;
  return gcd(m,w%m);
}

int solve(int *a){
  cnt=0;
  cout << gcd(a[0],a[1])<<" " << cnt << endl;
}

main(){
  int a[2];
  while(cin>>a[0]>>a[1]){
    if ( a[0]==0&&a[1]==0)break;
    if ( a[0]<a[1])swap(a[0],a[1]);
    solve(a);
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	int x, y;
	while(1){
		int count=0, tmp;
		cin>>x>>y;
		if(x == 0 && y == 0) break;
		while(1){
			if(y == 0) break;
				x = x % y;
				tmp = x;
				x = y;
				y = tmp;
				count++;
		}
		cout<<x<<" "<<count<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

int step = -1;
int result = 0;

int gcd(int a, int b) {
    step++;
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    while (true) {
       int X = 0, Y = 0;
       
       scanf("%d %d", &X, &Y);
       
       if(X == 0 && Y == 0) break;
       
       if (X < Y) {
           X = Y;
       }
       
       result = gcd(X, Y);
             
       printf("%d %d\n", result, step);
    }
    
    
    
    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

struct GCD{
	int gcd;
	int step;
};

GCD calc_gcd (int a, int b )
{
	GCD res;
	
	int step = 0;

	while(1){
		++step;
		if (a % b == 0){
			break;
		} // end if
		a = a % b;
		if (a < b ){
			swap (a, b );
		} // end if
//		cout << "a: " << a << " b: " << b << endl;
	} // end while

	res.gcd = b;
	res.step = step;

	return res;
}	

int main()
{
//	cut here before submit 
//	freopen("testcase.ea", "r", stdin);
	string str = "";

	while (getline (cin, str ) ){
		int a, b;
		stringstream ss (str );
		ss >> a >> b;

		if (a == 0 && b == 0){
			break;
		} // end if
		GCD res;

//		cout << "a: " << a << " b: " << b << endl;

		if (a < b ){
			swap (a, b );
		} // end if

		res = calc_gcd (a, b );
		cout << res.gcd << ' ' << res.step << endl;

	} // end loop

		
	return 0;
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int k;

int gcd(int a,int b){
	if(b==0)return a;
	k++;
	return gcd(b,a%b);
}

int main() {
	int a,b;
	while(cin>>a>>b,a){
		k=0;
		if(a>b){cout<<gcd(a,b);cout<<" "<<k<<endl;}
		else{cout<<gcd(b,a);cout<<" "<<k<<endl;}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int X, Y;

pair<int, int> gcd_cnt(int x, int y){
    int cnt = 0;
    while(y > 0){
        cnt++;
        x %= y;
        swap(x, y);
    }
    return make_pair(x, cnt);
}

int main(){
    while(cin >> X >> Y){
        if(X == 0 && Y == 0){
            return 0;
        }
        if(X < Y){
            swap(X, Y);
        }
        pair<int, int> ret = gcd_cnt(X, Y);
        cout << ret.first << " " << ret.second << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int a, b, r, kouyaku[1001], kazu[1001], kaisuu, s;
	kaisuu = 0;
	cin >> a >> b;

}

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

unsigned int res=0;

unsigned int gcd(unsigned int x,unsigned int y) {
  if(y == 0) return x;
  else {
    res++;
    return gcd(y,x%y);
  }
}

int main() {
 unsigned int x,y;
  while(cin >> x >> y) {
    if(x==0&&y==0) break;
    cout << gcd(x,y) << " " << res << endl;
    res = 0;
  }
}