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<stdio.h>
int main (void)
{
    int a,b,n,m;
	while(1){
		scanf("%d %d",&a,&b);
		if(a==0&&b==0) break;
	    n=1;
		while(1){
		    m=a%b;
			a=b;
			b=m;
			if(b==0){
			    printf("%d %d\n",a,n);
				break;
			}
			n++;
		}
	}
	return 0;
}

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

int main(){
	int x,y;
	while(cin >> x >> y){
		if(x == 0 && y == 0) break;
		int cnt=0;
		if(x < y){
			x^=y;
			y^=x;
			x^=y;
		}
		while(y){
			x %= y;
			if(x < y){
				x^=y;
				y^=x;
				x^=y;

				cnt++;
			}
		}
		cout << x << " " << cnt << endl;
	}
}

C++: #include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> VI;
typedef pair<int,int> PII;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define sz size()

const double EPS = 1e-10;
const int INF = 100000000;

int main(){
    int a,b;
    while(cin>>a>>b){
        if(!(a||b))break;
        int count=0;
        while(b!=0){
            int box=b;
            b=a%b;
            a=box;
            count++;
        }
        cout<<a<<" "<<count<<endl;
    }
    return 0;
}

C++: #include<iostream>

unsigned int c;

unsigned int gcd(unsigned int x, unsigned int y){
	if(y==0)
		return x;
	c++;
	return gcd(y, x%y);
}

int main(){
	unsigned int x, y;
	while(true){
		c = 0;
		std:: cin >> x >> y;
		if(x == 0 && y==0)
			return 0;
		std:: cout << gcd(x, y) << ' ' << c << std::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*y){
		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;

int main() {
  int x, y;
  while (cin >> x >> y, x | y) {
    if (x < y) {
      int tmp = x;
      x = y;
      y = tmp;
    }
    int cnt = 0;
    while (y) {
      int r = x % y;
      x = y;
      y = r;
      cnt++;
    }
    cout << x << " " << cnt << "\n";
  }
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<30;

typedef pair<int,int> pii;

pii gcd(int a, int b) {
  if (b == 0) {
    return pii(a, 0);
  }
  pii p = gcd(b,a%b);
  return pii(p.first, p.second + 1);
}

int main() {
  int a, b;
  while(cin >> a >> b, a||b) {
    pii p = gcd(a,b);
    cout << p.first << " " << p.second << endl;
  }
}

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


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

  scanf("%d %d", &a, &b);

  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<iostream>
using namespace std;
int m,n,o,cnt;
int main(){
  while(cin>>n>>m){
    if(n==0&&m==0)break;
    if(n<m){
      o=n;
      n=m;
      m=o;
    }
    cnt=0;
    while(m!=0){
      cnt++;
      o=n%m;
      n=m;
      m=o;
    }
    cout<<n<<' '<<cnt<<endl;
  }
}

C++: #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pp = pair<ll,ll>;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)
//fixed << setprecision(20)

int main(){
	ll a,b;
	while(true){
		cin >> a >> b;
		if(a == 0 && b == 0)break;
		ll x = max(a,b);
		ll y = min(a,b);
		int count = 0;
		while(y != 0){
			x = x % y;
			ll t = x;
			x = y;
			y = t;
			count++;
		}
		cout << x << " " << count << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <time.h>
#include <math.h>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <sstream>
#include <string>
#include <bitset>
using namespace std;
#define FOR(I,F,N) for(int I = F; I < (int)(N); I++)
#define rep(i, n) FOR(i, 0, n)
#define FIN(V) cout<<V<<endl
#define pb push_back
#define INF (1 << 30)
typedef pair<int, int> P;
typedef long long ll;
typedef priority_queue<int> pq;
int StrToInt(string);
string IntToStr(int);
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

int main(void){

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

	return 0;
}



int StrToInt(string s){
	stringstream ss;
	ss << s;
	int val;
	ss >> val;
	return val;
}
string IntToStr(int i){
	stringstream ss;
	ss << i;
	return ss.str();
}

C++: #include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main(){
    int a,b,i,j,x=0,y,count={0},memo;
    cin>>a>>b;
    if(a<=b){
        x=b;y=a;
    }else if(a>=b){
        x=a;y=b;
    }
    for(i=0;i<1000;i++){
        x=x%y;
        swap(x,y);
        count++;
        if(y==0){
            break;
        }
    }
    cout<<x<<" "<<count<<endl;
    return 0;
}

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

int res=0;

int gcd(int x, int y) {
  if(y == 0) return x;
  else {
    res++;
    return gcd(y,x%y);
  }
}

int main() {
  int x,y,temp;
  while(cin >> x >> y) {
    if(x==0&&y==0) break;
    if(x < y) {
      temp = x;
      x = y;
      y = temp;
    }
    cout << gcd(x,y) << " " << res << endl;
    res = 0;
  }
}

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

int search(int n,int m,int &count){
  if(n%m==0){return m;}
  else{count++; return search(m,n%m,count);}
}




int main(){
  while(1){
  int n,m,count=0;
  cin>>n>>m;
  if(n==0 && m==0){break;}
  int ans=search(n,m,count);
  cout<<ans<<" "<<count+1<<endl;
  }
  
  return 0;
}

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

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

        cout << M << " " << count << endl;
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

int take;

int gcd(int n, int m)
{
    take++;
    if (m == 0)
        return n;
    return gcd(m, n % m);
}

int main()
{
    int n, m;

    while (cin >> n >> m, n || m) {
        take = 0;
        int ans = gcd(n, m);
        cout << ans << " " << take - 1 << endl;
    }

    return 0;
}