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

C++: #include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define shosu(n) setprecision(n)
#define INF 1000000000;
using namespace std;
int main() {
  long long A, B;
  while (cin >> A >> B) {
    int step = 0;
    if (A == 0 && B == 0)
      break;
    if (A < B)
      swap(A, B);
    for (int i = 0; B > 0; i++) {
      A = A % B;
      swap(A, B);
      step++;
    }
    cout << A << ' ' << step << endl;
  }
  return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<vi> vvi;
typedef vector<vb> vvb;
typedef vector<vpii> vvpii;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
bool odd(const int &n) { return n & 1; }
bool even(const int &n) { return !odd(n); }
template<typename V> typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int x, y;
  while (cin >> x >> y, x) {
    int t = 0;
    if (x < y) swap(x, y);
    for (; y; t++) {
      x %= y;
      swap(x, y);
    }
    cout << x << ' ' << t << endl;
  }
}

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

int gcd(int a, int b, int cnt);

int main()
{
	int a, b;

	while (cin >> a >> b, a){
		int cnt = 0;
		gcd(max(a, b), min(a, b), cnt);
	}

	return (0);
}

int gcd(int a, int b, int cnt)
{
	if (b == 0){
		cout << a << " " << cnt << endl;
	}
	else {
		return (gcd(b, a % b, cnt + 1));
	}
}

C++: #include "bits/stdc++.h"

using namespace std;

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

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back


int main(){
    
    int a,b;
    int t1,t2;
    while( cin>>a>>b ){
        if(a==0&&b==0)break;
        if(a<b)swap(a,b);
        int c=0;
        while(1){
            c++;
            t1=b;
            t2=a%b;
            a=t1,b=t2;
            if(b==0){
                cout<<a<<" "<<c<<endl;
                break;
            }
        }
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(){
	long long int a,b;
	while(1){
		cin>>a>>b;
		if(a==0&&b==0)break;
		if(a<b)swap(a,b);
		int cnt=0;
		while(1){
			a%=b;
			swap(a,b);
			cnt++;
			if(b==0)break;
		}
		cout<<a<<" "<<cnt<<endl;
	}
}

C++: #include<iostream>

using namespace std;

typedef long long int;

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,x==0&&y==0){
		if(x<y){
			int tmp=x;
			x=y;
			y=tmp;
		}
		cout<<gcd(x,y)<<" "<<ct<<endl;
		ct=0;
	}
	return 0;
}

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

pair< int, int > rec(int X, int Y, int Step)
{
  if(Y == 0) return(make_pair(X, Step));
  else return(rec(Y, X % Y, Step + 1));
}

int main()
{
  int X, Y;
  while(cin >> X >> Y, X|Y) {
    pair< int, int > ret = rec(X, Y, 0);
    cout << ret.first << " " << ret.second << endl;
  }
}

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<cstdio>
using namespace std;
int main()
{
  int x, y, tmp;
  while(true)
  {
    cin >> x >> y;
    if(!x && !y)
      break;
    if(x < y)
    {
      tmp = y;
      y = x;
      x = tmp;
    }
    int i;
    for(i = 0; y; i++)
    {
      x = x % y;
      tmp = y;
      y = x;
      x = tmp;
    }
    printf("%d %d\n", x, i);
  }
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

int gcd(int w,int m,int &cnt){
  return m==0?w:gcd(m,w%m,++cnt);
}

int solve(int *a){
  int cnt=0;
  cout << gcd(a[0],a[1],cnt)<<" " << cnt << endl;
}

main(){
  int a[2];
  while(cin>>a[0]>>a[1]){
    if ( a[0]==0&&a[1]==0)break;
    if ( a[0]<a[1])swap(a[0],a[1]);
    solve(a);
  }
}

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;
    if(x < y) swap(x,y);
    int cou = 0;
    while(y != 0){
      tmp = x % y;
      x = tmp;
      swap(x,y);
      cou++;
    }
    cout << x << " " << cou << endl;
  }
}

C++: #include <stdio.h>
int T;
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); T = 0;
		if(a==0&&b==0) return 0;
		a=gcd(a,b);
		printf("%d %d\n",a, T);
	}
}