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>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

int depth;

long long int GCD(long long int a, long long int b){
	depth++;
	long long int rest = a % b;
	a = rest;
	swap(a, b);
	if(b == 0){
		return a;
	}
	return GCD(a, b);
}

int main(){
	
	long long int a, b;
	
	while(true){
		
		cin >> a >> b;
		
		if(a == 0 && b == 0){
			break;
		}
		
		depth = 0;
		
		if(a < b){
			swap(a, b);
		}
		
		long long int ans = GCD(a, b);
		
		cout << ans << " " << depth << endl;
		
	}
	
	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) {
            int tmp = N % M;
            N = M;
            M = tmp;
            count++;
        }

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

    return 0;
}

C++: #include<stdio.h>

int main(){
	int a,b;
	while(1){
		scanf("%d%d",&a,&b);
		if(!(a|b))return 0;
		int now=0;
		if(a<b){
			int c=a;
			a=b;
			b=c;
		}
		while(b!=0){
			a=a%b;
			int c=a;
			a=b;
			b=c;
			now++;
		}
		printf("%d %d\n",a,now);
	}
}

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

int x,y;

void swap(){
  int temp;
  temp = x;
  x = y;
  y = temp;
}

int main(){

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

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
int cnt(int x,int y)
{
	if(x < y) swap(x,y);
	if(y == 0) return 0;
	return cnt(y,x%y)+1;
}
int main()
{
	while(1)
	{
		int x,y;
		cin >> x >> y;
		if(x == 0 && y == 0) return 0;
		cout << __gcd(x,y) << " " << cnt(x,y) << endl;
	}
}

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++: #include <iostream>
using namespace std;

int main() {
	int x,y,y1,z,s;
	while(cin >> x >> y) {
		if (x==0 && y==0) break;
		if (x<y) { z=x; x=y; y=z;}
		s=y1=0; 
		while(y!=0){ z=x % y; y1=y; x=y; y=z; s++;}
		cout << y1 << ' ' << s << endl;
	}
	return 0;
}

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

int main()
{
  int x, y;
  int c, i;

  while (cin >> x >> y && x != 0){
    if (x < y){
      c = x;
      x = y;
      y = c;
    }

    for (i = 0; y != 0; i++){
      x = x % y;
      c = x;
      x = y;
      y = c;
    }

    cout << x << " " << i << endl;
  }
}

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

C++: #include<iostream>

using namespace std;

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;
	cin>>x>>y;
	cout<<gcd(x,y)<<" "<<ct<<endl;
	return 0;
}

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

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)<<" ";
		cout<<s<<endl;
	}
	return 0;
}

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

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

int main()
{
  int x, y;
  while (cin >> x >> y, x + y){
    int cnt = 0;
    while (y != 0){
      int tmp = y;
      y = x % y;
      x = tmp;
      cnt++;
    }
    cout << x << " " << cnt << endl;
  }
}

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

int main()
{
	vector<int>a(2);
	while (1) 
	{
		vector<int>a(2);
		cin >> a[1] >> a[0];
		if (a[0] == 0 && a[1] == 0)break;
		int o = 0;
		sort(a.begin(), a.end());
		while (1)
		{
			sort(a.begin(), a.end());
			if (a[1] % a[0] == 0)break;
			a[1] = a[1] % a[0];
			o++;
		}
		cout << a[0]<<" "<<o+1<<endl;
	}
}

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

int main() {
  for(int X, Y; cin >> X >> Y && (X|Y);) {
    if(X < Y) swap(X, Y);
    int t = 0;
    for(; Y; ++t) {
      X = X % Y;
      swap(X, Y);
    }
    cout << X << " " << t << endl;
  }
  return 0;
}

C++: #include<stdio.h>
long step;
long enclidean(long a, long b){
                step++;
                long c;
                c = a%b;
                if(c)return enclidean(b,c);
                else return b;
}
int main(){
        long a,b,c;

        while(scanf("%ld %ld",&a,&b), a+b != 0L){
                step = 0;
                if (a > b)
                        c = enclidean(a,b);
                else
                        c = enclidean(b,a);
                printf("%d %d\n",c,step);
        }
        return 0;
}

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;
        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 <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

bool solve() {
    int a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) { return false; }
    if (a < b) { swap (a, b); }

    int step = 0;
    while (b > 0) {
        ++step;
        int t = a % b;
        a = b;
        b = t;
    }
    cout << a << ' ' << step << endl;
    return true;
}

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