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

C++: #include<iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
	int x, y;
	while (1) {
		cin >> x >> y;
		if (x == 0 && y == 0)
			break;
		if (x < y)
			swap(x, y);
		int i=0;
		for (; y != 0; i++) {
			x %= y;
			swap(x, y);
		}
		cout << x << ' ' << i << endl;
	}
}

C++: #include<iostream>
using namespace std;
int main(){
  int x,y;

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

C++: #include <stdio.h>
int main(void) {
	long a1, a2, x, y;
	int amari,i=0;
	scanf("%ld %ld", &a1, &a2);	//1. 2number
	
	
	if(a1<a2){
		
		x = a2;
		y = a1;
	}	
	while(amari =! 0){
		amari = x % y;
		x = y;
		y = amari;
                i++;
	
	}
	
	printf("%ld %ld\n", x, i);
	
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	long long unsigned int x,y,i;
	while(1){
		cin>> x >> y;
		if(x+y==0)break;
		if(x<y){
			int tmp=x;
			x=y;
			y=tmp;
		}
		int counter=0;
		while(y!=0){
			x=x%y;
			int tmp=y;
			y=x;
			x=tmp;
			counter++;
		}
		cout << x <<" "<<counter<<endl;
	}
}

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