#include <stdio.h>

main () {

	int x, y;

	while (scanf("%d %d", &x, &y) != EOF)
		if (x > 0 && y > 0)
			printf("%6d %6d %4d\n", x, y, gcd(x,y));
	exit();
}

int gcd (int u, int v) {

	int t;

	if (u <= 0)
		return v;
	if (u < v) {
		t = u;
		u = v;
		v = t;
	}
	u = u - v;
	gcd(u, v);
}

