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 <bits/stdc++.h>
using namespace std;

using ll = long long;

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

//ll lcm(ll a, ll b) {
//    int g = gcd(a, b);
//    a /= g;
//    b /= g;
//    return a * b * g;
//}

int main() {
    int a, b;
    while(cin >> a >> b, a) {
        int cnt = 0;
        if(a < b) {
            swap(a, b);
        }
        int res = gcd(a, b, cnt);
        cout << res << ' ' << cnt << endl;
    }
}

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

C++: #include<bits/stdc++.h>
using namespace std;
int p;
int gcd(int a,int b){
  if(b==0)return a;
  p++;
  return gcd(b,a%b);
}
int main(){
  int a,b;
  while(cin>>a>>b,a){
    p=0;
    if(a<b)swap(a,b);
    cout<<gcd(a,b)<<' ';
    cout<<p<<endl;
  }
}

C++: // Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int x, y;
		cin >> x >> y;

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

		int X, Y;
		if(x>=y){
			X = x;
			Y = y;
		}
		else{
			X = y;
			Y = x;
		}

		int cnt = 0;
		do{
			X = X%Y;

			int tmp = X;
			X = Y;
			Y = tmp;

			cnt++;
		}while(Y!=0);

		cout << X << ' ' << cnt << '\n';
	}

	return 0;
}

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

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

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

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

    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int x,y,a,b;
  while(1){
    cin>>x>>y;
    if(x==0 && y==0)break;
    b=0;
    while(1){
      if(y==0)break;
      a=x%y;
      x=y;
      y=a;
      b++;
    }
    cout<<x<<" "<<b<<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;
        int ans = func(x,y);
        printf("%d %d\n",ans,cnt+1);
    }
    return 0;
}

C++: #include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>
#define pb(in,tmp) in.push_back(tmp)
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) loop(i,0,b)
#define all(in) in.begin(),in.end()
using namespace std;
int main(){
int a,b;
while(cin>>a>>b,a||b){
int co=0;
if(a<b)swap(a,b);
while(1){
if(b==0)break;
a=a%b;
swap(a,b);
co++;
}
cout<<a<<" "<<co<<endl;
}
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int a,b;
	cin >> a >> b;
	if(a == 0 && b == 0) break;
	int ans = 1;
	while(a % b != 0){
	    int temp = b;
	    b = a % b;
	    a = temp;
	    ans++;
	}
	cout << b << " " << ans << endl;
    }
    return 0;
}

C++: #include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
double dp[200][100];//動的計画法
int main(){
    long long a,b,cnt,tmp;
    while(cin>>a>>b,a){
        cnt=0;
        if(a<b){
            tmp=b;
            b=a;
            a=tmp;
        }
        while(b){
            a%=b;
            tmp=b;
            b=a;
            a=tmp;
            cnt++;
        }
        cout<<a<<" "<<cnt<<endl;
    }
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 27;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

typedef pair<P,Ps> PIS;
PIS team[10];

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

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

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

    if(a < b) swap(a, b);

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

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

  }

  return 0;

}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long X,Y,s,c=0;
	while(cin>>X>>Y){
		if(X==0 && Y==0) break;
		while(Y!=0){
			s = X % Y;
			X = s;
			swap(X,Y);
			c++;
		}
	cout<<X<<" "<<c<<endl;
	c=0;
	}
}

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

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

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

int cnt;

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

int main(){
  int n, m;
  while(cin >> m >> n){
    if(m == 0 && n == 0) break;
    cnt = -1;
    int g = gcd(m, n);
    cout << g << ' ' << cnt << endl;
  }
return 0;
}

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





int main(){
  long  x, y, s, t, u;

  while(1){
    s = 0;
    cin>>x>>y;
    if(x == 0 && y == 0) break;


    while(y != 0){
      x = x%y;
      t =max(x, y);
      u =min(x, y);
      x = t; y =u;
      s++;
    }

    cout<<x<<" "<<s<<endl;
    
  }

  
  return 0;
}