import java.util.Scanner;
import java.math.BigDecimal;

public class Main{


		public static long saidai(long a , long b){
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s == 0){
					c = t;
					break;
				}else if(t == 0){
					c = s;
					break;
				}else if(s > t){
					s = s % t;
				}else{
					t = t % s;
				}
				
			}
			
			
			return c;
		}
		
		public static  long saishou(long a , long b){
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s < t){
					s = s+a;
				}else{
					t = t+b;
				}
			
			}
			return c;
		}
		
       public static void main(String[] args){
       int i,j;
       long a,b,c,d,e,f;
       
    	long[] x = new long[60];
    	long[] y = new long[60];
    
        Scanner scan = new Scanner(System.in);
        
        i = 0;
        while(scan.hasNextLong()){
        	a = scan.nextLong();
        	b = scan.nextLong();
        	x[i] = saidai(a,b);
        	y[i] = saishou(a,b);
        	
        	i++;
        
        }
      
        
        j = 0;
        while(j < i){
        	
     		System.out.println(x[j] + " " + y[j]);
        	j++;
       		}
       		}
} import java.util.Scanner; Scanner java.util import java.math.BigDecimal; BigDecimal java.math public class Main{


		public static long saidai(long a , long b){
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s == 0){
					c = t;
					break;
				}else if(t == 0){
					c = s;
					break;
				}else if(s > t){
					s = s % t;
				}else{
					t = t % s;
				}
				
			}
			
			
			return c;
		}
		
		public static  long saishou(long a , long b){
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s < t){
					s = s+a;
				}else{
					t = t+b;
				}
			
			}
			return c;
		}
		
       public static void main(String[] args){
       int i,j;
       long a,b,c,d,e,f;
       
    	long[] x = new long[60];
    	long[] y = new long[60];
    
        Scanner scan = new Scanner(System.in);
        
        i = 0;
        while(scan.hasNextLong()){
        	a = scan.nextLong();
        	b = scan.nextLong();
        	x[i] = saidai(a,b);
        	y[i] = saishou(a,b);
        	
        	i++;
        
        }
      
        
        j = 0;
        while(j < i){
        	
     		System.out.println(x[j] + " " + y[j]);
        	j++;
       		}
       		}
} Main public static long saidai(long a , long b){
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s == 0){
					c = t;
					break;
				}else if(t == 0){
					c = s;
					break;
				}else if(s > t){
					s = s % t;
				}else{
					t = t % s;
				}
				
			}
			
			
			return c;
		} saidai {
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s == 0){
					c = t;
					break;
				}else if(t == 0){
					c = s;
					break;
				}else if(s > t){
					s = s % t;
				}else{
					t = t % s;
				}
				
			}
			
			
			return c;
		} long c c s s t; t s = a s a t = b t b while(true){
				if(s == t){
					c = s;
					break;
				}else if(s == 0){
					c = t;
					break;
				}else if(t == 0){
					c = s;
					break;
				}else if(s > t){
					s = s % t;
				}else{
					t = t % s;
				}
				
			} true {
				if(s == t){
					c = s;
					break;
				}else if(s == 0){
					c = t;
					break;
				}else if(t == 0){
					c = s;
					break;
				}else if(s > t){
					s = s % t;
				}else{
					t = t % s;
				}
				
			} if(s == t){
					c = s;
					break;
				}else if(s == 0){
					c = t;
					break;
				}else if(t == 0){
					c = s;
					break;
				}else if(s > t){
					s = s % t;
				}else{
					t = t % s;
				} s == t s t {
					c = s;
					break;
				} c = s c s break; if(s == 0){
					c = t;
					break;
				}else if(t == 0){
					c = s;
					break;
				}else if(s > t){
					s = s % t;
				}else{
					t = t % s;
				} s == 0 s 0 {
					c = t;
					break;
				} c = t c t break; if(t == 0){
					c = s;
					break;
				}else if(s > t){
					s = s % t;
				}else{
					t = t % s;
				} t == 0 t 0 {
					c = s;
					break;
				} c = s c s break; if(s > t){
					s = s % t;
				}else{
					t = t % s;
				} s > t s t {
					s = s % t;
				} s = s % t s s % t s t {
					t = t % s;
				} t = t % s t t % s t s return c; c long a a long b b public static  long saishou(long a , long b){
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s < t){
					s = s+a;
				}else{
					t = t+b;
				}
			
			}
			return c;
		} saishou {
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s < t){
					s = s+a;
				}else{
					t = t+b;
				}
			
			}
			return c;
		} long c c s s t; t s = a s a t = b t b while(true){
				if(s == t){
					c = s;
					break;
				}else if(s < t){
					s = s+a;
				}else{
					t = t+b;
				}
			
			} true {
				if(s == t){
					c = s;
					break;
				}else if(s < t){
					s = s+a;
				}else{
					t = t+b;
				}
			
			} if(s == t){
					c = s;
					break;
				}else if(s < t){
					s = s+a;
				}else{
					t = t+b;
				} s == t s t {
					c = s;
					break;
				} c = s c s break; if(s < t){
					s = s+a;
				}else{
					t = t+b;
				} s < t s t {
					s = s+a;
				} s = s+a s s+a s a {
					t = t+b;
				} t = t+b t t+b t b return c; c long a a long b b public static void main(String[] args){
       int i,j;
       long a,b,c,d,e,f;
       
    	long[] x = new long[60];
    	long[] y = new long[60];
    
        Scanner scan = new Scanner(System.in);
        
        i = 0;
        while(scan.hasNextLong()){
        	a = scan.nextLong();
        	b = scan.nextLong();
        	x[i] = saidai(a,b);
        	y[i] = saishou(a,b);
        	
        	i++;
        
        }
      
        
        j = 0;
        while(j < i){
        	
     		System.out.println(x[j] + " " + y[j]);
        	j++;
       		}
       		} main {
       int i,j;
       long a,b,c,d,e,f;
       
    	long[] x = new long[60];
    	long[] y = new long[60];
    
        Scanner scan = new Scanner(System.in);
        
        i = 0;
        while(scan.hasNextLong()){
        	a = scan.nextLong();
        	b = scan.nextLong();
        	x[i] = saidai(a,b);
        	y[i] = saishou(a,b);
        	
        	i++;
        
        }
      
        
        j = 0;
        while(j < i){
        	
     		System.out.println(x[j] + " " + y[j]);
        	j++;
       		}
       		} int i i j; j long a a b b c c d d e e f; f long[] x = new long[60]; x new long[60] 60 long[] y = new long[60]; y new long[60] 60 Scanner scan = new Scanner(System.in); scan new Scanner(System.in) i = 0 i 0 while(scan.hasNextLong()){
        	a = scan.nextLong();
        	b = scan.nextLong();
        	x[i] = saidai(a,b);
        	y[i] = saishou(a,b);
        	
        	i++;
        
        } scan.hasNextLong() scan.hasNextLong scan {
        	a = scan.nextLong();
        	b = scan.nextLong();
        	x[i] = saidai(a,b);
        	y[i] = saishou(a,b);
        	
        	i++;
        
        } a = scan.nextLong() a scan.nextLong() scan.nextLong scan b = scan.nextLong() b scan.nextLong() scan.nextLong scan x[i] = saidai(a,b) x[i] x i saidai(a,b) saidai a b y[i] = saishou(a,b) y[i] y i saishou(a,b) saishou a b i++ i j = 0 j 0 while(j < i){
        	
     		System.out.println(x[j] + " " + y[j]);
        	j++;
       		} j < i j i {
        	
     		System.out.println(x[j] + " " + y[j]);
        	j++;
       		} System.out.println(x[j] + " " + y[j]) System.out.println System.out System System.out x[j] + " " + y[j] x[j] + " " + y[j] x[j] x j " " y[j] y j j++ j String[] args args public class Main{


		public static long saidai(long a , long b){
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s == 0){
					c = t;
					break;
				}else if(t == 0){
					c = s;
					break;
				}else if(s > t){
					s = s % t;
				}else{
					t = t % s;
				}
				
			}
			
			
			return c;
		}
		
		public static  long saishou(long a , long b){
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s < t){
					s = s+a;
				}else{
					t = t+b;
				}
			
			}
			return c;
		}
		
       public static void main(String[] args){
       int i,j;
       long a,b,c,d,e,f;
       
    	long[] x = new long[60];
    	long[] y = new long[60];
    
        Scanner scan = new Scanner(System.in);
        
        i = 0;
        while(scan.hasNextLong()){
        	a = scan.nextLong();
        	b = scan.nextLong();
        	x[i] = saidai(a,b);
        	y[i] = saishou(a,b);
        	
        	i++;
        
        }
      
        
        j = 0;
        while(j < i){
        	
     		System.out.println(x[j] + " " + y[j]);
        	j++;
       		}
       		}
} public class Main{


		public static long saidai(long a , long b){
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s == 0){
					c = t;
					break;
				}else if(t == 0){
					c = s;
					break;
				}else if(s > t){
					s = s % t;
				}else{
					t = t % s;
				}
				
			}
			
			
			return c;
		}
		
		public static  long saishou(long a , long b){
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s < t){
					s = s+a;
				}else{
					t = t+b;
				}
			
			}
			return c;
		}
		
       public static void main(String[] args){
       int i,j;
       long a,b,c,d,e,f;
       
    	long[] x = new long[60];
    	long[] y = new long[60];
    
        Scanner scan = new Scanner(System.in);
        
        i = 0;
        while(scan.hasNextLong()){
        	a = scan.nextLong();
        	b = scan.nextLong();
        	x[i] = saidai(a,b);
        	y[i] = saishou(a,b);
        	
        	i++;
        
        }
      
        
        j = 0;
        while(j < i){
        	
     		System.out.println(x[j] + " " + y[j]);
        	j++;
       		}
       		}
} Main
import java.util.Scanner;
import java.math.BigDecimal;

public class Main{


		public static long saidai(long a , long b){
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s == 0){
					c = t;
					break;
				}else if(t == 0){
					c = s;
					break;
				}else if(s > t){
					s = s % t;
				}else{
					t = t % s;
				}
				
			}
			
			
			return c;
		}
		
		public static  long saishou(long a , long b){
			long c,s,t;
			s = a;
			t = b;
			while(true){
				if(s == t){
					c = s;
					break;
				}else if(s < t){
					s = s+a;
				}else{
					t = t+b;
				}
			
			}
			return c;
		}
		
       public static void main(String[] args){
       int i,j;
       long a,b,c,d,e,f;
       
    	long[] x = new long[60];
    	long[] y = new long[60];
    
        Scanner scan = new Scanner(System.in);
        
        i = 0;
        while(scan.hasNextLong()){
        	a = scan.nextLong();
        	b = scan.nextLong();
        	x[i] = saidai(a,b);
        	y[i] = saishou(a,b);
        	
        	i++;
        
        }
      
        
        j = 0;
        while(j < i){
        	
     		System.out.println(x[j] + " " + y[j]);
        	j++;
       		}
       		}
}