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 <iostream>
#include <fstream>
#include <typeinfo>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<25;
const double pi=acos(-1);
const double eps=1e-8;
const vi emp;

int x,y;

int gcd(int a,int b,int& t){
	t++;
	if(!b) return a;
	return gcd(b,a%b,t);
}

int main(){
	while(1){
		cin>>x>>y;
		if(!x&&!y) break;
		int t=0;
		cout<<gcd(x,y,t)<<' ';
		cout<<t-1<<endl;
	}
}

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

int main(){
  
  int X,Y,counter;

  while(1){

  cin >>X>>Y;

  if(X == 0 && Y == 0)break;

  counter=0;

  if(X < Y)swap(X,Y);

  while(Y != 0){
    X=X%Y;
    swap(X,Y);
    counter++;
  }
  
  cout <<X<<" "<<counter<<endl;
  
  } 

  return 0;
}

C++: #include<iostream>

unsigned int c;

unsigned int gcd(unsigned int X, unsigned int Y){
	unsigned x, y;
	if(Y > X)
		x = Y, y = X;
	else
		x = X, y = Y;
	x = x%y;
	unsigned tmp = x;
	x = y;
	y = tmp;
	c++;
	if(y == 0)
		return x;
	return gcd(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 main(){
	int x, y, tmp, count;
	while(cin>>x>>y, x&&y){
		if(x<y){
			tmp=x;
			x=y;
			y=tmp;
		}
		count=0;
		while(y!=0){
			x %= y;
			tmp=x;
			x=y;
			y=tmp;
			count++;
		}
		printf("%d %d\n", x, count);
	}
	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) return 0;
		R = gcd(X, Y);
		printf("%d %d\n", R, T);
	}
}

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

typedef long long ll;

int ct=0;

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

int main(){
	int x,y;
	while(1){
		scanf("%d%d",&x,&y);
		if(x==0 && y==0)break;
		if(x<y){
			int tmp=x;
			x=y;
			y=tmp;
		}
		cout<<gcd(x,y)<<" "<<ct<<endl;
		ct=0;
	}
	return 0;
}

C++: # include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
using namespace std;
using LL = long long;
constexpr int MOD = 1000000000 + 7;
constexpr int INF = 2000000000;
const double PI = acos(-1);

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

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 aa;
		}
		kaisuu = kaisuu + 1;
		s = 0;
		while (b!=0) {
			s = s + 1;
			r = a % b;
			a = b;
			b = r;
		}
		kouyaku[kaisuu] = a;
		kazu[kaisuu] = s;
	}
aa:;
	for (int i = 1; i <= kaisuu; i++) {
		cout << kouyaku[i] << " " << kazu[i] << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <complex>
#include <cstdio>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

int a,b;

void gcd(int a,int b,int c){
	if(!b)cout<<a<<" "<<c<<endl;
	else gcd(b,a%b,++c);
}

int main(){
	while(cin>>a>>b){
		if(!a)return 0;
		gcd(max(a,b),min(a,b),0);
	}
}

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

C++: #include <iostream>

using namespace std;

int counter;

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

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

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

using namespace std;

int counter;

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

int main(void){
   int a, b;
   int tmp;
    if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }

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

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

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define debug(n) cout<<__FILE__<<","<<__LINE__<<": #"<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();i++)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

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

int main()
{
	for(int a,b;cin>>a>>b,a|b;){
		pii res=gcd(max(a,b),min(a,b));
		cout<<res.first<<" "<<res.second<<endl;
	}
	
	return 0;
}

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

int main(){
	while(1){
	int a,b,c;
	cin>>a>>b;
	if(a==0 && b==0){break;}
	c=0;
	int count=0;
	while(b!=0){
count++;
	c=a%b;
	a=c;
	swap(a,b);

	}
	cout<<a<<" "<<count<<endl;
	}
}

C++: #include <iostream>
#include <stdio.h>
using namespace std;
int main(){
	int x,y;
	while(1){
		cin>>x>>y;
		if(x==0 && y==0) break;
		int step=0;
		while(y!=0){
			x = x%y;
			int t =x;
			x = y;
			y = t;
			step++;
		}
		cout<<x<<" "<<step<<endl;
	}

	return 0;
}