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 <stdio.h>
int t;
void swap(int &a,int &b){
    int temp=a;
    a=b;
    b=temp;
    return ;
}
int gcd(int a,int b){
    t++;
    a=a%b;
    swap(a,b);
    if(b==0)return a;
    return gcd(a,b);
}
int main(){
    int a,b;
    while(true){
        scanf("%d%d",&a,&b);
        if(a==0&&b==0)return 0;
        t=0;
        if(a<b)swap(a,b);
        printf("%d %d\n",gcd(a,b),t);
    }
}

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;
     while(cin>>a>>b){
        if(a == 0 && b == 0) break;
        counter = 0;
        cout<<gcd(a,b)<<" "<<counter<<endl;
     }
     return 0;
}

C++: #include <stdio.h>
int t;
void swap(int &a,int &b){
    int temp=a;
    a=b;
    b=temp;
    return ;
}
int gcd(int x, int y) {
    if(x == 0) return y;
    if(y == 0) return x;
    t++;
    if(x > y) return gcd(y, x % y);
    return gcd(x, y % x);
}
int main(){
    int a,b;
    while(true){
        scanf("%d%d",&a,&b);
        if(a==0&&b==0)break;
        t=0;
        printf("%d %d\n",gcd(a,b),t);
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
    int x, y, a, i, r;
    cin >> x >> y;
    while(x != 0 || y != 0){
        i = 0;
        
        if(y > x){
            a = x;
            x = y;
            y = a;
        }

        while(y != 0){
            r = x % y;
            x = r;
            r = y;
            y = x;
            x = r;
            i++;
        }
        
        cout << x << " " << i << endl;
        cin >> x >> y;
    }
    
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
int x,y,i;
int main(){
	while(cin>>x>>y&&x+y){
		if(y>x)swap(x,y);
		i=0;
		for(;y;i++){
			x%=y;
			swap(x,y);
		}
		cout<<x<<" "<<i<<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 ) {
			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>
#include <algorithm>

using namespace std;

typedef long long ll;

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

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

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

C++: #include <iostream>
#include <algorithm>
using namespace std;
int main() {
	while (1) {
		long long a, b, count = 0;
		cin >> a >> b;
		if (a == 0 && b == 0) return 0;
		if (a < b) swap(a, b);
		while (1) {
			count++;
			a = a%b;
			swap(a, b);
			if (b == 0) {
				cout << a << " " << count << endl;
				break;
			}
		}
	}
	return 0;
}

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

int step;

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

int main() {
  int a, b;

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

C++: #include <stdio.h>
int main(){
  long x,y,a,counter=0;

  while(1){
    scanf("%ld %ld",&x,&y);
    if(x==y==0)break;
    while(1){
      counter++;
      a=x%y;
      if(a==0)break;
      x=y;
      y=a;
    }
    printf("%ld %ld\n",y,counter);
    counter=0;
  }
  return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int dx[8] = {-1, 0, 1, 0, -1, -1, 1, 1};
int dy[8] = {0, -1, 0, 1, -1, 1, -1, 1};

int main() {
  int x, y;

  while(1) {
    cin >> x >> y;
    if(x+y == 0) break;
    int cnt = 0;
    while(y != 0) {
      x = x%y;
      swap(x, y);
      cnt++;
    } 
    cout << x << ' ' << cnt << endl;
  }
}

C++: #include <stdio.h>
int main(){
  long x,y,a;
  int counter=0;

  while(1){
    scanf("%ld %ld0",&x,&y);
    if(x==0||y==0)break;
    while(1){
      counter++;
      a=x%y;
      if(a==0)break;
      x=y;
      y=a;
    }
    printf("%ld %d\n",y,counter);
    counter=0;
  }
  return 0;
}

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

int main()
{
  int a, b;
  while(cin >> a >> b, a||b){
    int cnt = 0;

    while(b){
      a = a%b;
      swap(a, b);
      cnt++;
    }

    cout << a << " " << cnt << endl;

  }

  return 0;

}

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

int main() {
    int N, M;
    while (cin >> N >> M, N || M) {
        int count = 0;
        while (M) {
            int tmp = N % M;
            N = M;
            M = tmp;
            count++;
        }

        cout << N << " " << count << endl;
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

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

void solve()
{
	int m, n;
	while(cin >> m >> n)
	{
		if(!m && !n)
		{
			break;
		}
		if(m < n)
		{
			swap(m, n);
		}
		int count = 0;
		gcd(m, n, count);
	}
}

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