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

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

int main()
{
  int a, b;
  while (cin>>a>>b, a||b) {
    if (a > b) {
      a ^= b;
      b ^= a;
      a ^= b;
    }
    cnt = 0;
    cout<<euclid(a, b)<<" "<<cnt<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,x,y) for(int i=(x);i<(y);i++)
#define rrep(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

//?????§??¬?´???°
int gcd(int x, int y) {
	return y ? gcd(y, x%y) : x;
}

signed main() {
	for (int x, y; cin >> x >> y&&x;) {
		int cnt = 0;
		while (y) {
			cnt++;
			int xx = x;
			x = y;
			y = xx%y;
		}
		cout << x << " " << cnt << endl;		
	}
	return 0;
}

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

C++: #include<iostream>

using namespace std;

void swap(int&, int&);

int main(){
  int count;
  long x, y;

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

    if(x < y) swap(x, y);
    count = 0;
    while(y != 0){
      x %= y;
      swap(x, y);
      ++count;
    }

    cout << x << " " << count << endl;
  }
  return 0;
}

void swap(int& x, int& y){
  int z;
  z = x;
  x = y;
  y = z;
}

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


int main(void)
{
  int a, b, x, y, z, i=0;

  while(scanf("%d %d", &a, &b) != EOF)
  {

  if(a != 0 || b != 0)
  {
    if(a >= b)
    {
      x = a;
      y = b;
    }

    else
    {
      x = b;
      y = a;
    }

  do{
      x = x%y;
      z = x;
      x = y;
      y = z;
      i++;
     }while(y!=0);

  printf("%d %d\n", x, i);
  }

  return 0;
  }
}

C++: #include <stdio.h>

int main(void)
{
    int a, b, r;
    int count = 1;
    
    while(scanf("%d %d", &a, &b) != EOF) {
        if(a == 0 && b == 0) {
            break;
        }
        
        while( (r = a % b) != 0 ) {
            
            a = b;
            b = r;
            count++;
            
        }
        printf( "%d %d\n", b, count );
    }
    
    return 0;
}

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;
	if(a < b) swap(a,b);
	while(a % b != 0){
	    int temp = b;
	    b = a % b;
	    a = temp;
	    ans++;
	}
	cout << b << " " << ans << endl;
    }
    return 0;
}

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

int gcd( int x, int y, int* count )
{
	int t;
	*count = 0;
	if( x < y ){
		t = x;
		x = y;
		y = t;
	}
	while( 1 ){
		++*count;
		if( ( t = x % y ) == 0 ){
			break;
		}
		x = y;
		y = t;
	}
	return y;
}

int main()
{
	int x, y;
	while( cin >> x >> y  && ( x != 0 || y != 0 ) ){
		int count = 0;
		int g = gcd( x, y, &count );
		cout << g << " " << count << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int a, b;
int co;

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

int main(){
	while (cin >> a >> b&&a+b){
		co = 0;
		int ans = gcd(a, b);
		cout << ans << " " << co << endl;
	}
}

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

int GCD(int n, int m)
{
  cnt++;
  if (n == 0) return m;
  return GCD(m % n, n);
}

int main()
{
  int n, m;
  while (cin >> n >> m && n + m != 0){
    cnt = 0;
    if (n > m){
      int c = n;
      n = m;
      m = c;
    }
    cout << GCD(n, m) << " " << --cnt << endl;
  }
}

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;
    solve(a);
  }
}

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(y!=0){
      x = x % y;
      temp = x;
      x = y;
      y = temp;
      count++;
    }
    cout << x  << ' ' << count << endl;
  }
  return 0;
}

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){
		a=a%b;
		swap(a,b);
		count++;

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

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define ERASE(v,i) (v).erase(remove(all(v),i),(v).end())
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(it,c) for(typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define debug(x) cerr<<#x<<" = "<<(x)<<endl;
#define LINE cerr<<"LINE: "<<__LINE__<<endl;
inline int toInt(string s){int v;istringstream i(s);i>>v;return v;}
template<class T> inline string toString(T x){ostringstream o;o<<x;return o.str();}
template<class T> void pv(T a,T b){for(T it=a;it!=b;++it)cerr<<*it<<" ";cerr<<endl;}
const int INF = 1000000000;
const double EPS = 1e-10;

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