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"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

pair<ll,ll> gcd(ll a,ll b){
	if(a<b){
		swap(a,b);
	}

	ll sum=0;
	while(ll r=(a%b)){
		a = b;
		b = r;
		sum++;
	}
	return make_pair(b,sum+1);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	while(true){
		ll A=in(),B=in();
		if(!A && !B) break;

		auto res = gcd(A,B);
		out(res.first,res.second);
	}
	return 0;
}

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

using namespace std;

int main(){
  for(int h,l;cin>>h>>l,h|l;){
    if(h<l){
      swap(h,l);
    }
    int i;
    for(i=1;;i++){
      h=h%l;
      swap(h,l);
      if(l==0)break;
    }
    cout<<h<<' '<<i<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, b;
	while (cin >> a >> b&&a != 0) {
		if (a < b)swap(a, b);
		int num = 0;
		while (b) {
			a %= b;
			swap(a, b);
			++num;
		}
		cout << a << ' ' << num << 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;
	}
}

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

int c;

int gcd(int x,int y){
  if(x < y)swap(x,y);
  if(!y)return x;
  c++;
  return gcd(y,x%y);
}

int main(){
  int a,b;
  int ans;

  while(1){
    cin >> a >> b;
    if(!a && !b)break;

    c = 0;
    ans = gcd(a,b);
    cout << ans << " " << c << endl;
  }
}

C++: #include<iostream>
using namespace std;
int main(){
  int x,y,cnt;
  while(cin >> x >> y,x!=0&&y!=0){
    cnt = 1;
    while(x%y != 0){
    
      swap(x,y);
      y = y%x;
      
      cnt++;
    }
    cout << y << " " << cnt << 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 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>
using namespace std;

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

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

int GCD(int n, int m)
{
  cnt++;
  if (m % n == 0) return n;
  return GCD(m % n, n);
}

int main()
{
  int n, m;
  while (cin >> n >> m && n + m != 0){
    cnt = 0;
    if (n > m){
      int c = n;
      n = m;
      m = c;
    }
    cout << GCD(n, m) << " " << cnt << endl;
  }
}

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

using namespace std;

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

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

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

C++: #include<iostream>
#include<string>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<algorithm>
#include<complex>
using namespace std ;
typedef vector<int> vi ;
typedef vector<vi> vvi ;
typedef vector<string> vs ;
typedef pair<int, int> pii; 
typedef long long ll ;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()

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

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int cou;

int mygcd(int a,int b){
    cou++;
    if(b==0)return a;
    else return mygcd(b,a%b);
}

int main(){
    ios::sync_with_stdio(false);
    int a,b;
    while(cin >> a >> b,a){
        if(a<b)swap(a,b);
        int res = mygcd(a,b);
        cout << res << " " << cou-1 << endl;
        cou=0;
    }
}

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

using namespace std;

void change(int *, int *);

int main(void)
{
	int x, y;
	
	while(1){
		scanf("%d %d", &x, &y);
		if(x == 0 && y == 0)
		break;
		int count = 0;
		if(x < y)
			change(&x, &y);
		while(y){
			count++;
			x %= y;
			change(&x, &y);
		}
		cout << x << ' ' << count << endl;
	}
	return 0;
}

void change(int *a, int *b)
{
	int temp;
	temp = *a;
	*a = *b;
	*b = temp;
	
}

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

void EucledeanAlgorithm(long int a, long int b) {
	int step = 0;
	while (b != 0) {
		if (a < b) swap(a, b);
		a = a % b; swap(a, b); step++;
	}
	cout << a << " " << step << endl; return;
}

int main() {
	long int a, b;
	while (1) {
		cin >> a >> b; if (a == 0 && b == 0) break;
		EucledeanAlgorithm(a, b);
	}
	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, x;
    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)<<' ’;
       cout<<counter<<endl;
    }
    return 0;

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