#include <iostream>

using namespace std;
unsigned long long X,Y,K,AA,BB;
bool resenje;

void resiti(unsigned long long A,unsigned long long B)
{
	if(!A && !B)
	{
		if((X*Y)==AA && (X^Y)==BB)
		{
			resenje=true;
		}
		return ;
	}
	if(resenje) return ;
	K=K*2;
	X=X+K/2;
	resiti(A/4,B/2); 
	if(resenje) return ;
	Y=Y+K/2;
	resiti(A/4,B/2);
	if(resenje) return ;
	X=X-K/2;
	resiti(A/4,B/2);
	if(resenje) return ;
	Y=Y-K/2;
	resiti(A/4,B/2);
	K=K/2;
}

int main(int argc, char** argv) {
	unsigned long long A,B;
	int t,i;
	cin>>t;
	for(i=0;i<t;i++)
	{
		cin>>A>>B;
		AA=A;
		BB=B;
		X=Y=0;
		K=1;
		resenje=false;
		resiti(A,B);
		if(!resenje) cout<<-1<<endl;
		else cout<<X<<" "<<Y<<endl;
	}
	return 0;
}