Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	for scanner.Scan() {
		buf := strings.Split(scanner.Text(), " ")
		a, _ := strconv.Atoi(buf[0])
		b, _ := strconv.Atoi(buf[1])
		if a == 0 && b == 0 {
			break
		}
		if a < b {
			a, b = b, a
		}
		cnt := 0
		for b != 0 {
			a = a%b
			a, b = b, a
			cnt++
		}
		fmt.Println(a, cnt)
	}
}

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

#define iota(i,n,b,s) for(int i=int(b);i!=int((b)+(s)*(n));i+=(s))
#define range(i,n,m) iota(i,(((n)>(m))?((n)-(m)):((m)-(n))),(n),((n)>(m)?-1:1))
#define rep(i,n) iota(i,(n),0,1)
#define loop for(;;)

#define INF (1e9)
#define EPS (1e-9)
#define cons(a,b) (make_pair(a,b))
#define car(a) (a.first)
#define cdr(a) (a.second)
#define cadr(a) (car(cdr(a)))
#define cddr(a) (cdr(cdr(a)))
#define all(a) a.begin(), a.end()
#define trace(var) cerr<<">>> "<<#var<<" = "<<var<<endl;

typedef long long Integer;
typedef long double Real;
typedef vector<int> vi;
typedef vector<string> vs;
typedef map<string,int> Dictionary;
const Real PI = acos(-1);

template<class S, class T>
ostream& operator<<(ostream& os, pair<S,T> p) {
  os << '(' << car(p) << ", " << cdr(p) << ')';
  return os;
}

template<class T>
ostream& operator<<(ostream& os, vector<T> v) {
  if (v.size() == 0) {
    os << "(empty)";
    return os;
  }
  os << v[0];
  for (int i=1, len=v.size(); i<len; ++i) os << ' ' << v[i];
  return os;
}

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

char u[] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'};
int v[] =  {1, 5, 10, 50, 100, 500, 1000};

int value_of (char c) {
  rep (i, 7) {
    if (c == u[i]) return v[i];
  }
}

int div(int a, int b, int n) {
  a %= b;
  a = a * 10;
  if (n == 1) return (a/b);
  return div(a, b, n - 1);
}
bool* PrimeSieve(int n) {
  bool*s = new bool[n];
  for (int i = 0; i < n; ++i) s[i] = true;
  s[0] = s[1] = false;
  for (int i = 2; i < n; ++i)
    if (s[i]) for (int j = i << 1; j < n; j += i) s[j] = false;
  return s;
}

pair<int,int>gcd(int a,int b,int i=0){
  if(a>b)return gcd(b,a,i);
  if(a==0)return cons(b,i);
  return gcd(b%a,a,i+1);
}

int main() {

  loop {
    int a, b; cin >> a >> b;
    if (!a &&!b) break;
    auto p=gcd(a,b,0);
    cout<<car(p)<<' '<<cdr(p)<<endl;}

  return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,x,y) for(int i=(x);i<(y);i++)
#define rrep(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

//?????§??¬?´???°
int gcd(int x, int y) {
	return y ? gcd(y, x%y) : x;
}

signed main() {
	for (int x, y; cin >> x >> y&&x;) {
		int cnt = 0;
		while (y) {
			cnt++;
			int xx = x;
			x = y;
			y = xx%y;
		}
		cout << x << " " << cnt << endl;		
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int s,a,b;
int gcd(int x,int y){
	s++;
	return y?gcd(y,x%y):x;
}
int main(){
	while(cin>>a>>b,a)s=-1,cout<<gcd(a,b)<<" "<<s<<endl;
	return 0;
}

C++: // 2012/07/16 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int x, y;
		cin >> x >> y;

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

		int X, Y;
		if(x>=y){
			X = x;
			Y = y;
		}
		else{
			X = y;
			Y = x;
		}

		int cnt = 0;

		do{
			X = X%Y;

			int tmp = X;
			X = Y;
			Y = tmp;

			cnt++;
		}while(Y!=0);

		cout << X << ' ' << cnt << endl;
	}

	return 0;
}

C++: #include <cstdio>

using namespace std;

int main()
{
    while( 1 )
    {
        int num1 = 0, num2 = 0;
        scanf( "%d %d\n", &num1, &num2 );
        if( num1 == 0 && num2 == 0 )break;
        int cnt = 0;
        while( num2 != 0 )
        {
            int index = num2;
            num2 = num1 % num2;
            num1 = index;
            cnt++;
        }
        printf( "%d %d\n", num1, cnt );
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
 
int main(){
int x,y,z,ans;
	while(true){
		ans=0;
		cin>>x>>y;
		if(x==0||y==0)break;
		if(x<y){
			z=x;
			x=y;
			y=z;
		}
		while(y!=0){
		x=x%y;
		z=x;
		x=y;
		y=z;
		ans++;
		}
		cout<<x<<' '<<ans<<endl;
	}
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int x,y,s;
	while(cin>>x>>y,x){
		if(y>x)swap(x,y);
		for(s=0;y;)s++,x%=y,swap(x,y);
		cout<<x<<" "<<s<<endl;
	}
	return 0;
}

C++: #include<stdio.h>
int main (void)
{
    int a,b,n,m;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0) break;
	    n=1;
		while(1){
		    m=a%b;
			a=b;
			b=m;
			if(b==0){
			    printf("%d %d\n",a,n);
				break;
			}
			n++;
		}
	}
	return 0;
}

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

int main(){
	int x,y;
	while(cin >> x >> y){
		if(x == 0 && y == 0) break;
		int cnt=0;
		if(x < y){
			x^=y;
			y^=x;
			x^=y;
		}
		while(y){
			x %= y;
			if(x < y){
				x^=y;
				y^=x;
				x^=y;

				cnt++;
			}
		}
		cout << x << " " << cnt << 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(){
    int a,b;
    while(cin>>a>>b){
        if(!(a||b))break;
        int count=0;
        while(b!=0){
            int box=b;
            b=a%b;
            a=box;
            count++;
        }
        cout<<a<<" "<<count<<endl;
    }
    return 0;
}

C++: #include<iostream>

unsigned int c;

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

int main(){
	unsigned int x, y;
	while(true){
		c = 0;
		std:: cin >> x >> y;
		if(x == 0 && y==0)
			return 0;
		std:: cout << gcd(x, y) << ' ' << c << std::endl;
	}
}

C++: #include<iostream>

using namespace std;

int ct=0;

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

int main(){
	int x,y;
	while(cin>>x>>y,x*y){
		if(x<y){
			int tmp=x;
			x=y;
			y=tmp;
		}
		cout<<gcd(x,y)<<" "<<ct<<endl;
		ct=0;
	}
	return 0;
}

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

int main() {
  int x, y;
  while (cin >> x >> y, x | y) {
    if (x < y) {
      int tmp = x;
      x = y;
      y = tmp;
    }
    int cnt = 0;
    while (y) {
      int r = x % y;
      x = y;
      y = r;
      cnt++;
    }
    cout << x << " " << cnt << "\n";
  }
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

typedef pair<int,int> pii;

pii gcd(int a, int b) {
  if (b == 0) {
    return pii(a, 0);
  }
  pii p = gcd(b,a%b);
  return pii(p.first, p.second + 1);
}

int main() {
  int a, b;
  while(cin >> a >> b, a||b) {
    pii p = gcd(a,b);
    cout << p.first << " " << p.second << endl;
  }
}