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<cstdio>
using namespace std;
int main() {
	int a, b;
	int temp,masatoy=0;
	while (1) {
		cin >> a >> b;
		if (a == 0 && b == 0)return 0;
		while (b != 0) {
			a = a % b;
			temp = a;
			a = b;
			b = temp;
			masatoy++;
		}
		cout << a <<" "<<masatoy<< endl;
		masatoy = 0;
	}
}

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

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

C++: #include<bits/stdc++.h>
using namespace std;
#define lp(i,n) for(int i=0;i<n;i++)
#define lpin(a,i,n) for(int i=0;i<n;i++){cin>>a[i];}


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

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

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int x, y;
	while(cin >> x >> y && !(x == 0 && y == 0)){
		cnt = 0;
		if(x < y) swap(x, y);
		cout << gcd(x, y) << " ";
		cout << cnt << endl;
	}

	return 0;
}

C++: #define scanf_s scanf
#include <stdio.h>
#include<iostream>
#include <list>
#include <vector>
#include <iostream>
using namespace std;
#define MAX 101

int main()
{
	while (1) {
		int X, Y, r, cou = 0;
		scanf_s("%d %d", &X, &Y);
		if (X == 0 && Y == 0) break;
		if (X < Y) {
			r = X;	X = Y; Y = r;
		}
		 do{
			r = X % Y;
			X = Y; Y = r;
			++cou;
		 } while (r != 0);
		printf("%d %d\n", X, cou);
	}
}

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

C++: #include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
//#include <utility>
//#include <memory>
//#include <functional>
//#include <deque>
//#include <cctype>
//#include <ctime>
//#include <numeric>
//#include <list>
//#include <iomanip>

//#if __cplusplus >= 201103L
//#include <array>
//#include <tuple>
//#include <initializer_list>
//#include <forward_list>
//
//#define cauto const auto&
//#else

//#endif

using namespace std;


typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
int ans;
void gcd(ll x,ll y){
	if(x<y) swap(x,y);
	if(y==0) return;
	ans++;
	gcd(y,x%y);
}


void mainmain(){
	ll x,y;
	while(cin>>x>>y,x){
		ans=0;
		gcd(x,y);
		cout<<__gcd(x,y)<<" "<<ans<<endl;
	}
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

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

int counter;

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

int main(void){
   int a, b;
    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 <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, 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)<<" ";
            cout<<counter<<endl;   
            }    
            return 0;
    
}

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

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

C++: #include <iostream>
using namespace std;
   int gcd(int a, int b){
       if (b == 0) return a;
       else return gcd(b, a%b);
       counter++;
   }

int main(void){
   int a, b, counter;
    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 <stdio.h>

int main(void)
{
	int N;
	int n[4] = {0};
	int L, S;
	int i;
	int x;
	int tmp;
	int k;
	int c;
	int h;
	
	c = 0;
	
	while (1){
		scanf("%d", &N);
		
		if (N == 0){
			break;
		}
		h = 0;
		while (1){
			if (N == 6174){
				break;
			}
			for (k = 0; k <= 3; k++){
				n[k] = N % 10;
				N /= 10;
			}
			if (n[0] == n[1] && n[1] == n[2] && n[2] == n[3]){
				h = 1;
				break;
			}
			for (i = 0; i <= 3; i++){
				for (x = 0; x <= 3; x++){
					if (n[i] > n[x]){
						tmp = n[x];
						n[x] = n[i];
						n[i] = tmp;
					}
				}
			}
			L = 0;
			for (k = 0; k <= 3; k++){
				L = L * 10 + n[k];
			}
		
				for (i = 0; i <= 3; i++){
				for (x = 0; x <= 3; x++){
					if (n[i] < n[x]){
						tmp = n[x];
						n[x] = n[i];
						n[i] = tmp;
					}
				}
			}
			S = 0;
			for (k = 0; k <= 3; k++){
				S = S * 10 + n[k];
			}
			N = L - S;
			c++;
			
		}
		if (h == 0){
			printf("%d\n", c);
			c = 0;
		}
		else {
			printf("NA\n");
		}
	}
	return (0);
}