#include<stdio.h>

int main(int argc, char const *argv[])
{
	unsigned long long int n,k,tmp;

	scanf("%llu%llu",&n,&k);
	printf("%llu %llu\n",n,k );
	tmp=n+1;

	while(n<tmp){
		tmp=n;
		if(k>n){
			n=k-n;
		}else{
			n=n-k;
		}
	}

	printf("%llu\n",tmp );

	return 0;
}