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 <cassert>
//PXjUXeZStdX
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
// #include <boost/foreach.hpp>
// #include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
//#define INF 1e9
#define LINF (1LL<<40)
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};
typedef pair<int,int> P;

const long long MOD=1000000007LL;
bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)||islower(c));}

template<typename T> 
void print(vector<T> v){
    for(int i=0;i<v.size();i++){
        if(i)cout<<" ";
        cout<<v[i];
    }
    cout<<endl;
}
int INF=1e18;

template<typename T>
void printendl(vector<T> v){
    for(auto date:v)cout<<date<<endl;
}

template<typename T>
void printvv(vector<vector<T>> v){
    for(int i=0;i<v.size();i++){
        for(int j=0;j<v[i].size();j++){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}

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

int powl(int n,int p){
    int ret=1;
    for(int i=0;i<p;i++)ret*=n;
    return ret;
}

struct Edge{
    int to,cost;
};

struct S{
    int score[3];
    char team;
};

signed main (){
    int a,b;
    while(cin>>a>>b){
        if(a+b==0)break;
        int g=gcd(a,b);
        cout<<g<<" "<<ans-1<<endl;
        ans=0;
    }


    

    

    


}

/*

*/

C++: #include <stdio.h>
#include <math.h>

int main(void) {
	int a, b, n;
	int x, step;
	for (;;) {
		scanf("%d", &a);
		scanf("%d", &b);
		if (a >= 2 && a <= (pow(2.0, 31.0) - 1) && b >= 2 && b <= (pow(2.0, 31.0) - 1)) {
			if (a < b) {
				x = a;
				a = b;
				b = x;
			}
			step = 1;
			if (a != 0 && b != 0) {
				while (a%b != 0) {
					x = a % b;
					a = b;
					b = x;
					step++;
				}
				printf("%d %d\n", b, step);
			}

			else break;
		}
		else break;
	}
		
		

		return 0;
}

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

using namespace std;

int counter;

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

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

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){
	c=a%b;
	a=c;
	swap(a,b);

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

C++: #include<stdio.h>
int main(void)
{
    int x,y,w,c,i;
	scanf("%d %d",&x,&y);
	while(x!=0&&y!=0){
	    c=0;
		if(x<y){
            w=x;
            x=y;
            y=w;
        }
	    while(y!=0){
			    x=x%y;
				w=x;
				x=y;
				y=w;
				c++;
		}
	printf("%d %d\n",x,c);
	scanf("%d %d",&x,&y);
	}
	return 0;
}

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

using namespace std;

int main()
{
	while(true)
	{
		int x = 0, y = 0, count = 0;;

		cin >> x >> y;

		if(x == 0 && y == 0)
		{
			return false;
		}

		if(x < y)
		{
			swap(x, y);
		}

		for(count = 0; y != 0; count++)
		{
			x = x % y;

			swap(x, y);
		}

		cout << x << ' ' << count << endl;
	}
}

C++: #include<iostream>
using namespace std;
int main()
{
  int x,y;
  for(;cin>>x>>y,x;)
    {
      int step=0;
      for(;y!=0;step++)
        {
          x=x%y;
          swap(x,y);
        }
      cout<<x<<" "<<step<<endl;
    }
}

C++: #include <iostream>
using namespace std;
 
int gcd(int a, int b, int step);
 
int main()
{
    int a, b;
 
    while (cin >> a >> b, a){
        gcd(a, b, 0);
    }
 
    return (0);
}
 
void gcd(int a, int b, int step)
{
    if (b == 0){
        cout << a << " " << step << endl;
    }
    else if (a < b){
        return (gcd(a, b % a, step + 1));
    }
    else {
        return (gcd(b, a % b, step + 1));
    }
}

C++: #include<iostream>

using namespace std;

typedef long long ll;

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){
		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 <cstdio>

using namespace std;

int t, r;

int gcd( int x, int y )
{
    if( x == 0 ) return y;
    if( y == 0 )return x; t++;
    if( y < x ) return gcd( y, x % y );
    return gcd( x, y % x );
}

int main()
{
    while( 1 )
    {
        int num1 = 0, num2 = 0;
        scanf( "%d %d\n", &num1, &num2 );
        if( num1 == 0 && num2 == 0 )break;
        t = 0;
        r = gcd( num1, num2 );
        printf( "%d %d\n", r, t );
    }
    return 0;
}

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 long int tmp = y;
      y = x % y;
      x = tmp;
      cnt++;
    }
    cout << x << " " << cnt << endl;
  }
}