#include <stdio.h>
int gcd(int a, int *b) {int d=0;while (*b) {int c=a%(*b);a=*b,*b=c,d++;} *b=d;return a;}
int main() {int a,b;while (scanf("%d %d",&a,&b)!=EOF && (a || b)) a=gcd(a,&b),printf("%d %d\n",a,b);return 0;}