#include<iostream>
#include<cstdio>
using namespace std;

int YUK(int x,int y);
int SKB(double x,double y,double w);


int main(){
	int a,b;
	while(cin>>a>>b){
		int d;
		
		if(a>=b){
			d=YUK(a,b);
			cout<<YUK(a,b)<<endl<<SKB(a,b,d)<<endl;
			
		}
		else{
			d=YUK(b,a);
			cout<<d<<endl<<SKB(a,b,d)<<endl;
		}
		cout<<'\n';

	return 0;
	}
  
}

int YUK(int x, int y){
	int c = x%y;
	cout<<"余りは"<<c<<endl;
	if(c==0)
		return y;
	
	else
		return YUK(y,c);
}

int SKB(double x, double y, double w){
	double n = (x*y)/w;
	return (int)n;
}


	






	