package my;
import java.util.Scanner;
public class Test103
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int m=sc.nextInt();
int n=sc.nextInt();
int om=m;
int on=n;
while(n!=0) {
int r=m%n;
System.out.println(m+","+n+","+r);
m=n;
n=r;
}
System.out.println(om+"和"+on+"的最大公约数是"+m);
int c=om*on/m;
System.out.println(om+"和"+on+"的最小公倍数是"+c);
}
}