Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func gcd(x, y int) (int, int) {
	nSteps := 0
	for {
		if x < y {
			tmp := x
			x = y
			y = tmp
		}
		nSteps++
		if x%y == 0 {
			return nSteps, y
		}
		x = x % y
	}
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		a, _ := nextInt()
		b, _ := nextInt()

		if a == 0 && b == 0 {
			break
		}

		nSteps, p := gcd(a, b)
		fmt.Println(p, nSteps)
	}
}

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

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

int main() {
	for (int a, b; a = in(), b = in(), a || b;) {
		int c = 0;
		if (a < b)
			swap(a, b);
		while (b) {
			c++;
			a %= b;
			swap(a, b);
		}
		outl(a, ' ', c);
	}
}

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

#define FOR(i, x, y) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

int main()
{
  long long int x, y;
  while (cin >> x >> y, x + y){
    int cnt = 0;
    while (y != 0){
      long int tmp = y;
      y = x % y;
      x = tmp;
      cnt++;
    }
    cout << x << " " << cnt << endl;
  }
}

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 <cstdio>
#include<iostream>
#include <iomanip>

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==0&&b==0) break;
		if(b!=0) Euclidean(a,b,0);
		else cout<<"0 0"<<endl;
	}

    return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;






int ans;

void swap(int *a, int *b) {
	int t = *a;
	*a = *b;
	*b = t;
}

int gcd(int x, int y) {
	if (x < y)swap(&x, &y);
	if (y == 0)return x;
	ans += 1;
	//cout << ans << endl;
	x %= y;
	return gcd(y, x);
}




int main() {
	int x, y;
	while (cin >> x >> y && x > 0 && y > 0) {
		ans = 0;
		cout << gcd(x, y) << " " << ans << endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int x,y;
  while(1){
    cin>>x>>y;
    if(x==0 && y==0)break;
    if(x<y)swap(x,y);
    rep(i,max(x,y)){
      x=x%y;
      swap(x,y);
      if(y==0)break;
    }
    cout<<x<<" "<<i+1<<endl;
  }
}

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

C++: #include<iostream>
#include<string>
using namespace std;
int main(){
	long long x,y;
	while(true){
	cin>>x>>y;
	if(x==0&&y==0)
		break;
	int i=1;
	while(true){
		x%=y;
		int tmp=x;
		x=y;
		y=tmp;
		if(y==0)
			break;
		i++;
	}
	cout<<x<<" "<<i<<endl;
	}
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	long long int x,y,temp,X,cnt;
	while(1){
		cnt=0;
		scanf("%lld %lld",&x,&y);
		if(x==0&&y==0)break;
		if(x<=y){
			temp=x;
			x=y;
			y=temp;
		}
		while(1){
			if(y==0)break;
			cnt++;
			X=x%y;
			x=y;
			y=X;
		}
		printf("%lld %lld\n",x,cnt);
	}
	return 0;
}

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

int main(){
    int cnt;
    int a,b;
    int x,y,q,r;
    while(1){
        cnt = 0;
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        a = x;
        b = y;
        while(1){
            cnt++;
            q = x/y;
            r = x -q*y;
            if(r == 0) break;
            x = y;
            y = r;
        }
        cout << y << " " << cnt << endl;
    }
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

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

C++: #include <iostream>
using namespace std;
//ユークリッドの互除法を再帰で解くプログラム

int gcd(int a,int b,int count){
    if(b != 0){
        gcd(b,a%b,count+1);
    }else{
        cout << a << " " << count << endl;
    }
    return 0;
}

int main(){
    int a,b;
    while (cin >> a >> b) {
        if (a == 0 && b == 0){
            break;
        }else{
            gcd(max(a,b),min(a,b),0);
        }
    }
    return 0;
}

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

int main()
{
    int a, b;

    while( cin >> a >> b )
    {
        if( a == 0 && b == 0 )
            break;
        int c = 0;
        if( a < b )
        {
            int temp = a;
            a = b;
            b = temp;
        }
        while( b != 0 )
        {
            int temp = b;
            b = a % b;
            a = temp;
            c++;
        }
        cout << a << " " << c << endl;
    }

    return 0;
}