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

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

int gcd(int a, int b, int step);

int main()
{
	int a, b;

	while (cin >> a >> b, a){
		gcd(a, b, 0);
	}

	return (0);
}

int gcd(int a, int b, int step)
{
	if (b == 0){
		cout << a << " " << step << endl;
	}
	else if (a < b){
		return (gcd(a, b % a, step + 1));
	}
	else {
		return (gcd(b, a % b, step + 1));
	}
}

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

int res;

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

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

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

struct result{
  int step;
  int gcd;
};

void gcd(int a, int b, result* r);

int main(void){
  int a,b;
  result r;
  while(1){
    cin>>a>>b;
    if(a==0 and b==0)break;
    gcd(a,b,&r);
    cout<<r.gcd<<" "<<r.step<<endl;
  }
  return 0;
}

void gcd(int _a, int _b, result* r){
  int step=0;
  int a=min(_a,_b);
  int b=max(_a,_b);
  while(a!=0){
    int tmp=b%a;
    b=a;
    a=tmp;
    step+=1;
  }
  r->step=step;
  r->gcd=b;
}

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

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

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <vector>
#include <set>

using namespace std;
typedef long long LL;
static const double EPS = 1e-9;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n) 

int main(void){  
  int a,b,m,n;
  while(cin>>a>>b,a||b){
    m = max(a,b);
    n = min(a,b);
    int count = 0;
    while(n!=0){
      int tmp = n;
      n = m%n;
      m = tmp;
      count++;
    }
    cout << m << " " << count << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
main() {
	int x, y;
	while ( cin >> x >> y && !(x == 0 && y == 0) ) {
		if ( y > x ) swap(x, y);
		int step = 0;
		while(y) {
			int t = x % y;
			x = y;
			y = t;
			step++;
		}
		cout << x << " " << step << endl;
	}
}

C++: #include <iostream>

using namespace std;

int main() {
	long long int x, y;
	long long int kari;
	while (cin >> x >> y) {
		if (x == 0 && y == 0) {
			break;
		}
		if (x < y) {
			kari = x;
			x = y; 
			y = kari;
		}
		int counter = 0;
		while (y != 0) {
			counter++;
			x = x % y;
			kari = y;
			y = x;
			x = kari;
		}
		cout << x << " " << counter << endl;
	}
	return 0;
}

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;    
        while(cin>>a>>b){  
            if(a == 0 && b == 0) 
            return 0;        
            counter = 0;     
            cout<<gcd(a,b)<<" ";
            cout<<counter<<endl;   
            }  
            return 0;
        
    }

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

int main(){
    long int cnt;
    long long a,b;
    long long x,y,q,r;
    while(1){
        cnt = 0;
        cin >> x >> y;
        if(x == 0 && y == 0) break;
        a = x;
        b = y;
        while(1){
            q = x/y;
            r = x -q*y;
            cnt++;
            if(r == 0) break;
            x = y;
            y = r;
        }
        cout << y << " " << cnt << endl;
    }
}

C++: #include <iostream>

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 <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int cnt;
int main(){
	int a,b;
	cnt=0;
	while(1){
		cin>>a>>b;
		if(a<b)swap(a,b);
		while(1){
			a%=b;
			swap(a,b);
			cnt++;
			if(b==0)break;
		}
		cout<<a<<" "<<cnt<<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;
		printf("%d %d\n",gcd(a,b), T);
	}
}

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





int main(){
  long  x, y, s, t, u ,z;

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

    if(x <= y) swap(x, y);
    
    while(y != 0){
      x = x%y;
      t =max(x, y);
      u =min(x, y);
      x = t; y =u;
      s++;
    }

    cout<<x<<" "<<s<<endl;
    
  }

  
  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
//#define int long long
using namespace std;

int X, Y;

pair<int, int> gcd_count(int X, int Y)
{
	int count = 0;

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

	return make_pair(X, count);
}

signed main()
{
	while (true)
	{
		cin >> X >> Y;
		if (X == 0 && Y == 0) break;

		if (X < Y) swap(X, Y);
		pair<int, int> ans = gcd_count(X, Y);
		
		cout << ans.first << " " << ans.second << endl;
	}
}