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++: // #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef vector<pair<int, int> > VPII;

#define MP make_pair
#define fastIO	cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c)	for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(), c_end=c.end(); it!=c_end; ++it)

// ------------------- include, typedef, define END. -------------------

void solveAndOutput(LL x,LL y){
	int step = 0;
	while (y != 0){
		step++;
		x = x%y;
		swap(x, y);
	}
	cout << x << " " << step << endl;
}

int main(){
	fastIO;
	LL x = 0, y = 0;
	while (cin >> x >> y, x || y){
		if (x < y)	swap(x, y);
		solveAndOutput(x, y);
	}
	return 0;
}

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) 
            return 0;        
            counter = 0;     
            cout<<gcd(a,b)<<" "<<counter<<endl;   
            }  
            return 0;
        
}

C++: #include <bits/stdc++.h>

using namespace std;

int main(){

  int X,Y,c=0;

  while(true){
    cin>>X>>Y;
    if(X+Y==0) break;
    c=0;
    while(true){
      X %= Y;
      swap(X,Y);
      ++c;
      if(Y==0){
	cout << X << " " << c << endl;
	break;
      }
    }
  }

  
  return 0;
}

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, x;
    while(cin>>a>>b){
        if(a < b){
            x = a;
            a = b;
            b = x;
        }
        if(a == 0 && b == 0)    return 0;
        counter = 0;
        cout<<gcd(a,b)<<" "<<counter<<endl;
    }
    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(void){
  int a,b;
  while(cin>>a>>b,a+b){
    step = 0;
    cout<<gcd(max(a,b),min(a,b));
    cout<<" "<<step<<endl;
  }
}

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

int main(){

  int x,y,x1,y1;
  int cnt=0;

  while(1)
    {
      cin >> x >> y;

      if(x==0 && y==0)
	{
	  break;
	}

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

      while(1)
	{
	  x = x%y;
	  swap(x,y);
	  
	  cnt++;
	  if(y == 0)break;
	}
	
      cout << x << " " << cnt << endl;
    }
}

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

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
	long long x, y;
	while(1){
		int count=0, tmp;
		cin>>x>>y;
		if(x == 0 && y == 0) break;
		while(1){
			if(y == 0) break;
				x = x % y;
				tmp = x;
				x = y;
				y = tmp;
				count++;
		}
		cout<<x<<" "<<count<<endl;
	}
	return 0;
}

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

using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+9
#define EPS 1e-9
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < (k); i++)
typedef long long ll;
int cnt;
int func(int x,int y){
    if(x%y == 0)return y;
    ++cnt;
    func(y,x%y);
}
int main(){
    int x,y;
    while(scanf("%d%d",&x,&y),(x|y)){
        cnt = 0;
        if(x < y)swap(x,y);
        int ans = func(x,y);
        printf("%d %d\n",ans,cnt+1);
    }
    return 0;
}

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

int main(void){
    int a, b;
    int tmp;
    while(true){
        cin >> a >> b;
        if(a + b == 0) break;
        if(a < b){
            tmp = a;
            a = b;
            b = tmp;
        }

        //ユークリッドの互除法
        int r, c = 0; //余り、ステップ数
        while(true){
            r = a % b;
            c++;
            if(r == 0) break;
            a = b;
            b = r;
        }
        cout << b << " " << c << endl;
    }   
}

C++: #include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

const int INF = 1001001001;

pii gcd(int a, int b)
{
	if(b == 0)
		return pii(a, 0);
	pii ret = gcd(b, a%b);
	ret.second++;
	return ret;
}

int main()
{
	int a, b;
	while(scanf("%d%d", &a, &b), a){
		if(a < b)
			swap(a, b);
		pii ret = gcd(a, b);
		printf("%d %d\n", ret.first, ret.second);
	}
}

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

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    ll a,b;
    while(cin>>a>>b){
        if(a<b)swap(a,b);
        int count=0;
        if(a==0 && b==0)break;
        while(b!=0){
            a=a%b;
            swap(a,b);
            count++;
        }
        cout<<a<<" "<<count<<endl;
    }
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
    int n,m,i,a;
	while(1){
	    scanf("%d %d",&n,&m);
		if(n==0&&m==0) break;
		a=0;
		if(n<m){
		i=n;
		n=m;
		m=i;
		while(1){
		    i=n%m;
			n=m;
			m=i;
			a++;
			if(m==0) break;
		}
		printf("%d %d\n",n,a);
	}
	return 0;
}

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