#include <bits/stdc++.h>
#include <math.h>
using namespace std;

int main()
{
	long long int a,b,x,y;
	long long int m;

	cin >> a >> b;

	for ( long long int k = 1; k <= sqrt(a); k++ )
	{
		if ( a%k == 0 )
		{
			m = a/k;
			if ( k^m == b )
			{
				cout << k << " " << m;
				break;
			}
		}
	}

	return 0;
}