#include<iostream>
using namespace std;

int T; long long A,B;
long long x,y;
int xn[20],yn[20], b[20];
int i,j,n;

void rek(int br){
	if(br == i){
		for(j = 0;j<i;j++){
			x = x*2 + xn[i];
			y = y*2 + yn[i];
		}
		if(x*y == A) cout << x << ' ' << y;
		else return;
		return;
		
			
	}
	if(b[br] ){
		xn[br] = 1;
		yn[br] = 1;
		rek(br+1);
		xn[br] = 0;
		yn[br] = 0;
	}
	else {
		xn[br] = 1;
		yn[br] = 0;
		rek(br+1);
		xn[br] = 0;
		yn[br] = 1;
	}
	
}


main(){
	ios::sync_with_stdio(false);
	cin >> A >> B;
	xn[0] = 1; yn[0] = 1;
	while(B>0){
		b[i] = B%2;
		B = B/2;
		i++;
	}
	rek(1);
}