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 <iostream>

using namespace std;

int main(int argc, char** argv)
{
	int n, m;
	int x, y, d, c;

	while(cin >> n >> m, n || m)
	{
		if(n >= m)
		{
			x = n;
			y = m;
		}
		else
		{
			x = m;
			y = n;
		}

		c = 0;
		while(y != 0)
		{
			d = x % y;
			x = y;
			y = d;
			c++;
		}

		cout << x << " " << c << endl;
	}

	return 0;
}

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

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

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

int cnt;

int gcd(int a,int b){ 
  if(a==0 || b==0) return 0;
  if(a<b) swap(a,b);
  while(b!=0) {
    a%=b;
    swap(a,b);
    cnt++;
  }
  return a;
}

int main() {
  int a,b;
  while(cin >> a >> b && (a!=0 || b!=0)) {
    cnt=0;
    int g=gcd(a,b);
    cout << g << " " << cnt << endl;
  }
  return 0;
}

C++: #include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b,a!=0){
    int c=0;
    if(b==a){
     cout<<a<<" "<<1<<endl;
     goto at;
   }
   int x,y;
   if(a>b){
     x=a,y=b;
   }else{
     x=b,y=a;
   }
   while(y>0){
     x=x%y;
     int s=x;
     x=y;
     y=s;
     c++;
   }
   cout<<x<<" "<<c<<endl;
 at:;
 }
 return 0;   
}

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