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(void){
	int x,y,t;
	while(1){
		int i=0;
		cin >> x >> y;
		if(x == 0 && y == 0) break;
		else if(x < y){
			t = x;
			x = y;
			y = t;
		}while(y !=0){
			x %=y;
			t = x;
			x = y;
			y = t;
			i +=1;
		}cout << x << " " << i << endl;
		
	}
}

C++: #include <bits/stdc++.h>

using namespace std;;

int main(){
  long xbox[1000];
  long ybox[1000];
  int size=0;
  long xtemp,ytemp;
  long x,y,swap,mod;
  int step;
  
  while(true){
    scanf("%ld %ld", &xtemp,&ytemp);
    if(xtemp == 0 && ytemp == 0) break;
    xbox[size] = xtemp;
    ybox[size] = ytemp;
    //printf("%d %d\n", xbox[size],ybox[size]);
    size++;
    }
  //size=1;
  //xbox[0] = 1071;
  //ybox[0] = 1029;
  for(int i=0; i<size; i++){
    step = 0;
    x = xbox[i];
    y = ybox[i];
    while(y!=0){
      mod = x%y;
      //printf("mod %d\n",mod);
      x = mod;
      swap = x;
      x = y;
      y = swap;
      step++;
    }
    printf("%ld %d\n", x,step);
  }
}

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<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  unsigned int c,x,y;
  for(;;){
    cin>>x>>y;
    if(x+y==0)
      break;
    if(x<y)
      swap(x,y);
    for(c=0;y;c++){
      x%=y;
      swap(x,y);
    }
    cout<<x<<" "<<c<<endl;
  }
  return 0;
}

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

C++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double eps = 1e-8;

int main(){
	int a,b;
	while(~scanf("%d %d",&a,&b)){
		if(a==b && b==0) break;

		int X,Y;
		if(a>=b){
			X = a;
			Y = b;
		}
		else{
			X = b;
			Y = a;
		}

		int count = 0;
		while(Y!=0){
			X = X % Y;
			swap(X,Y);
			count++;
		}

		printf("%d %d\n",X,count);
	}
}

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

int main() {
    int a, b;
    while (cin >> a >> b, a) {
        int cnt = 0;
        if (a < b) swap(a, b);
        while (b) {
            cnt++;
            swap(a = a % b, b);
        }
        cout << a << " " << cnt << endl;
    }
    return 0;
}

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)
#define int long long
int cnt;

int gcd(int w,int m){
  if ( m ==0)return w;
  cnt++;
  return gcd(m,w%m);
}

int solve(int *a){
  cnt=0;
  cout << gcd(a[0],a[1])<<" " << 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<algorithm>

using namespace std;

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

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 main() 
{
	int a, b, tmp, count;
    while (1) {
    	cin >> a >> b;
        if (a == 0 && b == 0) {
            break;
        }
        if(a < b) { 
                    tmp = b; 
                    b = a; 
                    a = tmp; 
                    } 
        count = 0; 
        do {
            a = a % b;
            tmp = b;
            b = a;
            a = tmp;
            count++;
        } while (b != 0);
        cout << a << " " << count << 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;) {
		if (x < y)swap(x, y);
		int cnt = 0;
		while (y) {
			cnt++;
			int xx = x;
			x = y;
			y = xx%y;
		}
		cout << x << " " << cnt << endl;		
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void){
	for (int i = 0; i < 1000; i++){
		int a,b;
		cin >> a >> b;

		if (a == 0 && b == 0)
			break;

		int j,r,COUNT = 1;

		if (b > a){
			j = a;
			a = b;
			b = a;
		}

		while((r = a % b) != 0)
			{ a = b; b = r; COUNT++;}

		cout << b << " " <<COUNT << endl;
	}

	return 0;
}

C++: #include <iostream>
using namespace std;
int main() 
{
	int a, b, tmp, count;
    while (1) {
    	cin >> a >> b;
        if (a == 0 && b == 0) {
            break;
        }
        if(a < b) { 
                    tmp = b; 
                    b = a; 
                    a = tmp; 
                    } 
        count = 0; 
        do {
            a = a % b;
            tmp = b;
            b = a;
            a = tmp;
            count++;
        } while (b != 0);
        cout << a << " " << count << endl;
    }
	return 0;
}

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