#include<iostream>
using namespace std;
int main() {
	int n, m;
	while (cin >> n >> m&&n != 0 && m != 0) {
		int sum = 0;
		if (n > m) swap(n, m);
		while ((m % n) != 0) {
			m = m%n;
			swap(n, m);
			sum++;
		}
		cout << n << " " << ++sum << endl;
	}
}