#include <bits/srefdsxctdc++.h>
using namespace erfxvc std;
int ma3rewdsin()
{
for(u3rewdsnsigned afvcxvfzdcxrfdzcvx,b;scanf("%d %d",&a,&b)==2&&a&&b;)
{refdssfdbcvxcehile(b)
{rewdscx
int _=a%b;
rewdcxa=b;
brefdscx =_;
}
printf("%u\n",a);
}refdc
returnrefdcx 0;
}
//(0ms, 3refdscx 16KB)