#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int main(void)
{
	int cnt=0;;
	int i,j,n,m,amari,syo;
	while(1) {
		scanf("%d %d",&n,&m);
		if(n==0 && m==0) break;
		if(n<m) swap(n,m);
		while(1) {
			n=n%m;
			swap(n,m);
			cnt++;
			if(m==0) break;
		}
		printf("%d %d\n",n,cnt);
	}
	return 0;
}
		
		