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>
using namespace std;
int main() {
	int a, b,r, kouyaku[1111], kazu[1111],kaisuu,s;
	kaisuu = 0;
	while (1) {
		cin >> a >> b;
		if (a == 0&&b == 0) {
			goto a;
		}
		kaisuu = kaisuu + 1;
		s = 0;
		while (b != 0) {
			s = s + 1;
			r = a % b;
			a = b;
			b = r;
		}
		kouyaku[kaisuu] = a;
		kazu[kaisuu] = s;
	}
a:;
	for (int i = 1; i <= kaisuu; i++) {
		cout << kouyaku[i]<<" " << kazu[i] << endl;
	}
}

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

C++: #define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

PII solve(int x, int y) {
	int a1, a2 = 0;
	if (x < y)swap(x, y);

	while (y != 0) {
		x = x % y;
		swap(x, y);
		a2++;
	}
	a1 = x;

	return mp(a1, a2);
}

int main() {
	while (true) {
		int x, y; cin >> x >> y;
		if (x == 0 && y == 0)break;

		PII a = solve(x, y);
		Cout2(a.first, a.second);
	}
}

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

int main(){
	while(1){
	int a,b,c;
	cin>>a>>b;
	if(a==0 && b==0){break;}

	int count=0;
	while(b!=0){
	count++;
	a=a%b;
	swap(a,b);

	}
	cout<<a<<" "<<count<<endl;
	}
}

C++: #include <cstdio>
#include <algorithm>

using namespace std;

int step;

int gcd(int x, int y)
{
	if (x < y) swap(x, y);
	if (y == 0) return (x);
	step++;
	return (gcd(y, x % y));
}

int main()
{
	int a, b;
	
	while (scanf("%d %d", &a, &b) && a){
		step = 0;
		int ans = gcd(a, b);
		printf("%d %d\n", ans, step);
	}
	return (0);
}

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

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 <cstdio>
#include<iostream>
#include <iomanip>

using namespace std;

void Euclidean(int a,int b,int n){
	if(b!=0) Euclidean(b,a%b,n+1);
	else cout<<a<<" "<<n<<endl;
	return;
}

int main(void){

	int a,b;

	while(1){

		cin>>a>>b;
		if(a==0&&b==0) break;
		Euclidean(a,b,0);
	}

    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

pair<int,int> gcd(int a,int b,int cnt){
	if(b==0)
		return make_pair(a,cnt);
	else
		return gcd(b,a%b,cnt+1);
}

int main(){

	int x,y;
	while(cin>>x>>y&&!(x==0&&y==0)){
		if(y>x){
			swap(x,y);
		}
		pair<int,int> p=gcd(x,y,0);
		cout<<p.first<<" "<<p.second<<endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int x,y;
	while(cin>>x>>y,x|y){
		if(x<y)swap(x,y);
		int count=0;
		while(y){
			x%=y;
			swap(x,y);
			count++;
		}
    cout<<x<<" "<<count<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<climits>
#include<math.h>
#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++: #include <bits/stdc++.h>
using namespace std;

int main() {
    long long int N, M;
    while (cin >> N >> M, N || M) {
        int count = 0;
        if (M > N) {
            int tmp = N;
            N = M;
            M = tmp;
        }
        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 counter;
   int gcd(int a, int b){
       if (b == 0) return a;
       else return gcd(b, a%b);
       counter++;
   }

int main(void){
   int a, b, counter;
    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<vector>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<iomanip>

using namespace std;


long long int yuku(long long int x,long long int y){
	long long int t=x%y;
	x=y;
	y=t;
	if(y==0)return x;
	else yuku(x,y);


};
long long int yu(long long int x,long long int y,long long int sum){
	long long int t=x%y;
	x=y;
	y=t;
	sum++;
	if(y==0)return sum;
	else yu(x,y,sum);


};
 
int main(){

long long int x,y;
while(1){
cin>>x>>y;if(x==y&&x==0)break;
if(y>x)swap(x,y);
long long int R=yuku(x,y);
long long int sum=0;
sum=yu(x,y,sum);

cout<<R<<" "<<sum<<endl;
}
return 0;
}