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<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<utility>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+9
#define EPS 1e-9
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < (k); i++)
typedef long long ll;
int cnt;
int func(int x,int y){
    if(x%y == 0)return y;
    ++cnt;
    func(y,x%y);
}
int main(){
    int x,y;
    while(scanf("%d%d",&x,&y),(x|y)){
        cnt = 0;
        if(x < y)swap(x,y);
        int ans = func(x,y);
        printf("%d %d\n",ans,cnt+1);
    }
    return 0;
}

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

int main(void){
    int a, b;
    int tmp;
    while(true){
        cin >> a >> b;
        if(a + b == 0) break;
        if(a < b){
            tmp = a;
            a = b;
            b = tmp;
        }

        //ユークリッドの互除法
        int r, c = 0; //余り、ステップ数
        while(true){
            r = a % b;
            c++;
            if(r == 0) break;
            a = b;
            b = r;
        }
        cout << b << " " << c << endl;
    }   
}

C++: #include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;

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

int main()
{
	int a, b;
	while(scanf("%d%d", &a, &b), a){
		if(a < b)
			swap(a, b);
		pii ret = gcd(a, b);
		printf("%d %d\n", ret.first, ret.second);
	}
}

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

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

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

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<21)

bool cmp(const pair<int,char> &a,const pair<int,char> &b){
	return a.first > b.first;
}
int main(){
	int x,y;
	while(cin >> x >> y , x){
		int ans = 0;
		if(y>x)swap(x,y);
		while(y){
			x = x%y;
			swap(x,y);
			ans++;
		}
		cout << x << " " << ans << endl;
	}
}

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

	for (int i = 0; i < 1000; i++){
		cin >> a >> b;

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

		int r,COUNT = 1;

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

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

	return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int gcd(int a, int b){
       if (b == 0) return a;
       else return gcd(b, a%b);
       counter++;
   }

int main(void){
   int a, b, counter;
    while(cin>>a>>b){
    if(a < b){
           x = a;
           a = b;
           b = x;
       }
       if(a == 0 && b == 0)    return 0;
       counter = 0;
       cout<<gcd(a,b)<<" "<<counter<<endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(void){

  int x,y;

  while( cin >> x >> y , x || y ){

    int count = 0;
    while(y){
      int s = x % y;   
      int temp = y;
      y = s;
      x = temp;
      count++;
    }
    cout << x << " " << count << endl;
  }
  return 0;
}

C++: #include <stdio.h>
int X, Y, T, R;
int gcd(int x, int y) {
	if(x == 0) return y;
	if(y == 0) return x; T++;
	if(x > y) return gcd(y, x % y);
	return gcd(x, y % x);
}
int main() {
	while(true) {
		scanf("%d%d", &X, &Y); T = 0;
		if(X == 0 && Y == 0) break;
		R = gcd(X, Y);
		printf("%d %d\n", R, T);
	}
	return 0;
}

C++: // 2011/07/07 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int X, Y;
		cin >> X >> Y;
		if(X==0&&Y==0)
			break;

		if(X<Y){
			int tmp = X;
			X = Y;
			Y = tmp;
		}

		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 <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
long long a,b;
int ans;
int gcd(long long x,long long y){
  ans+=1;
  if(x%y==0){
    return y;
  }else{
    gcd(y,x%y);
  }
}
int main()
{
  while(cin>>a>>b,a||b){
    ans = 0;
    if(a>=b){
      cout<< gcd(a,b)<<" ";
      cout <<ans<<endl;
    }else{
      cout<<gcd(b,a)<<" ";
      cout <<ans<<endl;
    }
  }
  return 0;
}

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

	a:;
		for (int i = 1; i <= kaisuu; i++) {
			cout << kouyaku[i] << " " << kazu[i] << endl;
		}
	}
}