#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
#include<vector>
#include<stack>
#include<queue>
#include<iostream>
using namespace std;
int main(void)
{
	int i,j,cnt,n,m;
	while(1) {
		cin>>n>>m;
		if(n==0&&m==0)break;
		if(n<m) swap(n,m);
		cnt=1;
		while(1) {
			n=n%m;swap(n,m);
			if(m==0) break;
			else cnt++;
		}
		cout<<n<<" "<<cnt<<endl;
	}
}
	