#include <stdio.h>

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