#include<algorithm>
#include<iostream>
#include<utility>

typedef std::pair<int, int> P;

P gcd( int s, int a, int b )
{
	if( b == 0 )
		return P( a, s );

	return gcd( s + 1, b, a % b );
}

int main()
{
	int a, b;
	while( std::cin >> a >> b, a | b )
	{
		P p = gcd( 0, std::max( a, b ), std::min( a, b ) );
		std::cout << p.first << ' ' << p.second << std::endl;
	}

	return 0;
}