https://www.acmicpc.net/problem/2436
import java.util.Scanner;
public class Main {
public static void main(String args[]) {
Scanner s=new Scanner(System.in);
int a=s.nextInt();
int b=s.nextInt();
int num=b/a;
int f=1;
int l=1;
int min=1000000000;
for(int i=1;i<Math.sqrt(num);i++){
int c=0;
int j=0;
if(num%i==0){
j=num/i;
for(int k=2;k<=i;k++){
if(i%k==0 && j%k==0){
c=1;
break;
}
}
if(c==0){
if(i+j<=min){
f=i;
l=j;
min=i+j;
}
}
}
}
System.out.format("%d %d",f*a,l*a);
}
}