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<algorithm>
using namespace std;
int main(){
  long long int x,y;
  while(cin >> x >> y,x){
    int count=0;
    while(y){
      x=x%y;
      swap(x,y);
      count++;
    }
    cout << x << " " << count << 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;

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

  return 0;
}

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

int main()
{
  int a, b, x, y;
  while( cin >> a >> b, a+b ) {
    int cnt = 0;
    if( a >= b ) { 
      x = a;
      y = b;
    } else {
      x = b;
      y = a;
    }

    while( y ) {
      x = x % y;
      swap(x, y);
      cnt++;
    }

    cout << x << " " << cnt << endl;
  }

}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){
	int x, y, rest, cnt;

	while (cin >> x >> y, x) {
		if (x < y) {
			rest = x;
			x = y;
			y = rest;
		}
		cnt = 0;
		while(true) {
			++cnt;
			rest = x%y;
			if (rest == 0) {
				break;
			}
			x = y;
			y = rest;
		}
		cout << y << " " << cnt << endl;
	}

	return 0;
}

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

int main()
{

	int x,y;

	while(true){
		int z=0;
		int c=0;

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

		while(true){
			x = x % y;
			z = x;
			x = y;
			y = z;

			c++;			

			if(y==0)
				break;
		}

		cout << x << ' ' << c << endl;
	}
	return 0;
}

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

using namespace std;

int counter;

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

   }

int main(void){
   int a, b;
   

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

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){
		cout<<gcd(x,y)<<" "<<ct<<endl;
		ct=0;
	}
	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;
  cout << gcd(a[0],a[1])<<" " << 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]);
    assert(a[0]>2 && a[1]>2);
    solve(a);
  }
}

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

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int a, b;
	while (cin >> a >> b, a || b) {
		int c = max(a, b), d = min(a, b);
		int r;
		int cnt(0);
		while (d) {
			cnt++;
			r = c%d;
			c = d;
			d = r;
		}
		cout << c << " " << cnt << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int a, b;
int co;

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

int main(){
	while (cin >> a >> b&&a+b){
		if (a < b)swap(a, b);
		co = 0;
		int ans = gcd(a, b);
		cout << ans << " " << co << 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 (1) {
			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<cstdio>
#include<iostream>
using namespace std;
int main(void){
	int x,y,temp,cnt;
	while(1){
		cin>>x>>y;
		if(x+y==0)break;
		if(x<y){
			temp=x;
			x=y;
			y=temp;
		}
		cnt=0;
		while(1){
			x=x%y;
			temp=x;
			x=y;
			y=temp;
			cnt++;
			if(y==0) break;
		}
		cout<<x<<' '<<cnt<<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, 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)<<" "<<counter<<endl;
   }
   return 0;
}

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

using namespace std;

void Euclidean(long long a,long long b,long long n){
	if(b!=0) Euclidean(b,a%b,n+1);
	else cout<<a<<" "<<n<<endl;
	return;
}

int main(void){

	long long a,b;

	while(1){

		cin>>a>>b;
		if(a<b) swap(a,b);
		if(a==0&&b==0) break;
		if(b!=0) Euclidean(a,b,0);
		else cout<<"0 0"<<endl;
	}

    return 0;
}

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


int counter;

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

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

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

ll s;

ll gcd(ll x, ll y) {
    if (x < y) swap(x, y);
    x %= y;
    swap(x, y);
    s++;
    return y ? gcd(x, y) : x;
}

int main() {
    ll a, b;
    while (cin >> a >> b && !(a == 0 || b == 0)) {
        s = 0;
        ll g = gcd(a, b);
        cout << g << ' ' << s << 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;
			y=tmp;
			x=y;
		}
		cout<<gcd(x,y)<<" "<<ct<<endl;
		ct=0;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;

void func(ll a, ll b, ll cnt) {
	if (!b)cout << a << ' ' << cnt << endl;
	else func(b, a%b, cnt + 1);
}
int main() {
	ll a, b;
	while (cin >> a >> b, a | b) {
		if (a < b)swap(a, b);
		func(a, b, 0);
	}
}