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++: /* 
 * File:   main.cpp
 * Author: freebsd
 *
 * Created on 2014/08/28, 10:07
 */

#include <cstdio>
#include <algorithm>

using namespace std;

long long int step = -1;
long long int result = 0;

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

int main() {
    while (true) {
       long long 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", result, step);
    }
    
    
    
    return 0;
}

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

C++: #include<iostream>
#include<algorithm>
#include<cassert>
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;
  int g = gcd(a[0],a[1]);
  cout << g<<" " << 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 <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n,m,c,t;
	while(cin >> n >> m,n || m){
		c = 1;
		if(m > n) swap(n,m);
		while(n % m != 0){
			t = n % m;
			n = m;
			m = t;
			++c;
		}
		cout << m << " " << c << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int X,Y,s,c=0;
	while(cin>>X>>Y){
		if(X==0 && Y==0) break;
		while(Y!=0){
			s = X % Y;
			X = s;
			swap(X,Y);
			c++;
		}
	cout<<X<<" "<<c<<endl;
	c=0;
	}
}

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

int main(){
    long int cnt;
    unsigned long long a,b;
    unsigned long long x,y,q,r;
    while(1){
        cnt = 0;
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        y = min(x,y);
        x = max(x,y);
        a = x;
        b = y;
        while(1){
            q = x/y;
            r = x -q*y;
            cnt++;
            if(r == 0) break;
            x = y;
            y = r;
        }
        cout << y << " " << cnt << endl;
    }
}

C++: #include<iostream>
using namespace std;
int main()
{
  while(true){
    int X,Y;
    int ans = 0;
    cin >> X >> Y;
    if( X == Y && Y == 0 ) break;
    if( Y > X ) swap( X, Y );

    do{
      X=X%Y;
      swap(X,Y);
      ++ans;
    }while(Y!=0);

    cout << X << ' ' << ans << endl;
  }
  return 0;
}

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

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

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>

using namespace std;


long long int yuku(long long int x,long long int y){
	long long int t=x%y;
	x=y;
	y=t;
	if(y==0)return x;
	else yuku(x,y);


};
long long int yu(long long int x,long long int y,long long int sum){
	long long int t=x%y;
	x=y;
	y=t;
	sum++;
	if(y==0)return sum;
	else yu(x,y,sum);


};
 
int main(){

long long int x,y;
while(1){
cin>>x>>y;if(x==y&&x==0)break;
long long int R=yuku(x,y);
long long int sum=0;
sum=yu(x,y,sum);

cout<<R<<" "<<sum<<endl;
}
return 0;
}

C++: #include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

long long calc(long long x,long long y,long long int& count){

	int tmp_count = 0,tmp;

	while(y != 0){
		tmp = y;
		y = x%y;
		x = tmp;
		tmp_count++;
	}

	count = tmp_count;
	return x;
}

int main(){

	long long a,b,count,number;

	while(true){
		scanf("%lld %lld",&a,&b);
		if(a == 0 && b == 0)break;

		if(a > b){
			number = calc(a,b,count);
		}else{
			number = calc(b,a,count);
		}

		printf("%lld %lld\n",number,count);

	}

    return 0;
}

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

void swap(int *a, int *b){
	if(*a != *b){
		*a ^= *b;
		*b ^= *a;
		*a ^= *b;
	}
}

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

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[8] = {0, -1, 0, 1, -1, 1, -1, 1};

int main() {
  int x, y;

  while(1) {
    cin >> x >> y;
    if(x+y == 0) break;
    if(x < y) swap(x, y);
    int cnt = 0;
    while(y != 0) {
      x = x%y;
      swap(x, y);
      cnt++;
    } 
    cout << x << ' ' << cnt << endl;
  }
}