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 <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define SUBIF(a, b, x) ((x) ? (b) : (a))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647LL
#define MOD 1000000007LL
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using namespace std;


int a, b;


PII solve(){
	if(a < b) swap(a, b);
	int cnt = 1;
	int r = a%b;
	while(r > 0){
		a = b;
		b = r;
		r = a%b;
		cnt++;
	}
	return { b, cnt };
}


int main(){
	while(cin >> a >> b, a && b){
		PII ans = solve();
		cout << ans.first << ' ' << ans.second << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>

using namespace std;

int counter = 0;

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

int main(void){
    int a, b;
     cin>>a>>b;
    cout<<gcd(a,b)<<" "<<counter<<endl;
     return 0;
}

C++: #include <iostream>

using namespace std;

int main(int argc, char **argv)
{
	int x, y, tmp, c;
	
	while(1){
		cin >> x >> y;
		if(x == 0 && y == 0){
			break;
		}
		c = 0;
		if(x < y){
			tmp = x;
			x = y;
			y = tmp;
		}
		
		while(y > 0){
			tmp = x % y;
			x = y;
			y = tmp;
			c++;
		}
		
		cout << x << " " << c << endl;
	}
	
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>


int main(void)
{
	int result[10000], step[10000];
	int suffix = 0;

	while (1) {
		long long x, y;

		scanf("%lld", &x);
		scanf("%lld", &y);

		if (x == 0 && y == 0) {
			break;
		}

		long long value = 1;
		int count = 0;

		while (1) {
			count++;
			value = x % y;

			if (value == 0) {
				result[suffix] = y;
				step[suffix] = count;
				suffix++;
				break;
			}

			x = y;
			y = value;
		}
	}

	for (int i = 0; i < suffix - 1; i++) {
		printf("%d %d\n", result[i], step[i]);
	}

	printf("%d %d", result[suffix - 1], step[suffix - 1]);

	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>

using namespace std;

int gcd(int a, int b, int &c){
  if(a>b) swap(a,b);
  if(a==0)return b;
  c++;
  return gcd(a, b%a, c);
}

int main(){
  int a,b,c;
  while(scanf("%d%d",&a,&b), a+b){
    c = 0;
    int d = gcd(a,b,c);
    printf("%d %d\n",d,c);
  }
  return 0;
}

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<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>

using namespace std;

#define MAX -210000000
#define MIN 210000000

int main(){
	int a,b,c,d,cunt;
	
	scanf("%d %d",&a,&b);
	while(a!=0 && b!=0){
		cunt=0;
		if(a<b){
			d=a;
			a=b;
			b=d;
		}
		
		d=a%b;
		if(d==0) cunt++;
		
		while(d!=0){
			cunt++;
			d=a%b;
			a=b;
			b=d;
			if(a<b){
				d=a;
				a=b;
				b=d;
			}
		}
		
		printf("%d %d\n",a,cunt);
		scanf("%d %d",&a,&b);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int a, b, r, kouyaku[1001], kazu[1001], kaisuu, s;
	kaisuu = 0;
	cin >> a >> b;
	for (int i = 1; i <= kaisuu; i++) {
		cout << kouyaku[i] << " " << kazu[i] << endl;
	}
}

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

void swap( int &a, int &b ){
	int tmp = a;
	a = b;
	b = tmp;
}

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

C++: #include <cstdio>
#include<iostream>
#include <iomanip>

using namespace std;

void Euclidean(long long a,long long b,long long n){
	if(b!=0) Euclidean(b,a%b,n+1);
	else cout<<a<<" "<<n<<endl;
	return;
}

int main(void){

	long long a,b;

	while(1){

		cin>>a>>b;
		if(a==0&&b==0) break;
		Euclidean(a,b,0);
	}

    return 0;
}

C++: #include <cstdio>
#include <algorithm>
int ans = 0;
int GCD(int a, int b){
	if(b==0)return a;
	ans++;
	return GCD(b, a%b);
}

int main(){
	int x,y;
	while(scanf("%d %d",&x, &y), x+y){
		ans=0;
		if(x>y)std::swap(x,y);
		int gcd = GCD(x,y);
		printf("%d %d\n",gcd, ans);
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>

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

using namespace std;

int ans;

void gcd(int x,int y)
{
	ans++;
	x = x % y;
	swap(x,y);

	if(y == 0)
	{
		cout << x << " " << ans << endl;
		return;
	}
	else gcd(x,y);
}

int main()
{
	int a,b;
	while(cin >> a >> b)
	{
		if(a == 0 && b == 0) break;

		ans = 0;

		if(a < b) swap(a,b);
		gcd(a,b);	
	}
	return 0;
}

C++: #include <stdio.h>
int main(){
  long x,y,a;
  int counter=0;

  while(1){
    scanf("%ld %ld0",&x,&y);
    if(x==y==0)break;
    while(1){
      counter++;
      a=x%y;
      if(a==0)break;
      x=y;
      y=a;
    }
    printf("%ld %d\n",y,counter);
    counter=0;
  }
  return 0;
}

C++: #include<stdio.h>

int main(){
	int x,y,count,t;
	while(0<=scanf("%d%d",&x,&y)){
		if(x==0 && y==0)break;
		if(x<y){
			count=x;
			x=y;
			y=count;
		}
		count=0;
		while(y!=0){
			x=x%y;
			t=x;
			x=y;
			y=t;
			++count;
		}
		printf("%d %d\n",x,count);
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int x, y;
        cin >> x >> y;
        if(x == 0)
            return 0;
        if(x < y)
            swap(x, y);

        int ret = 0;
        do{
            ++ ret;
            x %= y;
            swap(x, y);
        }while(y != 0);

        cout << x << ' ' << ret << endl;
    }
}

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

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

void EucledeanAlgorithm(long int a, long int b) {
	int step = 0;
	while (b != 0) {
		if (a < b) swap(a, b);
		a = a % b; swap(a, b); step++;
	}
	cout << a << " " << step << endl; return;
}

int main() {
	long int a, b;
	while (1) {
		cin >> a >> b; if (a == 0 && b == 0) break;
		EucledeanAlgorithm(a, b);
	}
	return 0;
}