#include <iostream>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(int argc, char** argv) {
	unsigned a[100],b[100];
	unsigned x[100],y[100];
	int t,i;
	cin>>t;
	for (i=0;i<t;i++)
	{
		cin>>a[i];
		cin>>b[i];
	}
	for (i=0;i<t;i++)
	{
		for(x[i]=1;x[i]<=a[i]/2;x[i]++)
		{
			for(y[i]=1;y[i]<=a[i]/2;y[i]++)
			{
				if (x[i]*y[i]==a[i] && (x[i]^y[i])==b[i])
				{
					break;
				}
			}
		if (x[i]*y[i]==a[i] && x[i]^y[i]==b[i])
			{
				break;
			}
		}
	}
	for (i=0;i<t;i++)
	{
		if(x[i]*y[i]==a[i] && x[i]^y[i]==b[i])
			{
				cout<<x[i]<<" "<<y[i]<<endl;
			}
		else
		{
			cout<<"-1"<<endl;
		}	
	}
	
	return 0;
}