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>
#include<iostream>
#include <vector>
#include <cstdio>
#include<algorithm>
#include <utility>
#define SIZE 1001;
using namespace std;
int main() {
	long long count=0, x, y;
	while (1) {
		cin >> x >> y;
		if (x == 0 && y == 0) {
			break;
		}
		if (y > x) {
			swap(x, y);
		}
		while (1) {
			if (y == 0) {
				break;
			}
			count++;
			x %= y;
			swap(x, y);
		}
		cout << x <<" "<<count<<  endl;
		count = 0;
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int ct;

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<bits/stdc++.h>
using namespace std;





int main(){
  int x, y, s, amari;

  while(1){
    s = 0;
    cin>>x>>y;
    if(x == 0 && y == 0) break;


    while(1){
      x = x%y;
      swap(x, y);
      s++;
      if(y == 0)break;
    }

    cout<<x<<" "<<s<<endl;
    
  }

  
  return 0;
}

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

  long long int res;

  long long int gcd(  long long int x,   long long int y) {
  if(y == 0) return x;
  else {
    res++;
    return gcd(y,x%y);
  }
}

int main() {
  long long int x,y;
  while(cin >> x >> y) {
    if(x==0 && y==0) break;
    if(x < y) {
      swap(x,y);
    }
    res = 0;
    cout << gcd(x,y) << " " << res << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int p;
int gcd(int a,int b){
  if(b==0)return a;
  p++;
  return gcd(b,a%b);
}
int main(){
  int a,b;
  while(cin>>a>>b,a){
    p=0;
    if(a<b)swap(a,b);
    cout<<gcd(a,b)<<' ';
    cout<<p<<endl;
  }
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int x,y,z;
int swap(){
  z = x;
  x = y;
  y = z;
  return 0;
}

int main(){
  while(true){
    cin>>x>>y;
    if(!x&&!y)break;
    int step = 0;
    if(y>x)swap();
    while(y!=0){
      x = x%y;
      swap();
      step++;
    }
    cout<<x<<" "<<step<<endl;
  }
  return 0;
}

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

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

C++: #include <iostream>

using namespace std;

void GCD(int x, int y, int c)
{
	if(y == 0)
	{
		cout << x << " " << c << endl;
		return;
	}
	GCD(y, x % y, c + 1);
}

void solve()
{
	int x, y;
	while(cin >> x >> y, x || y)
	{
		if(x >= y)
		{
			GCD(x, y, 0);
		}
		else
		{
			GCD(y, x, 0);
		}
	}
}

int main()
{
	solve();
	return(0);
}

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

int p = 0;

void gcd(int x,int y){
  p++;
  if(y == 0){
    cout<<x<<' '<<p-1<<endl;
    return;
  }

  gcd(y,x%y);
}

int main(){

while(1){
  int x,y;
  cin >> x >> y;
  if(x == 0 && y == 0)break;
  gcd(x,y);
  int p = 0;
  //cout << x << " " << p-1 << endl;
  //int tmp =gcd(x,y,p);
  //cout <<  tmp << " " << p << endl;
}
  return 0;
}

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;
	}
}