#include<bits/stdc++.h>
using namespace std; 
main()
{
	int T,i;
	scanf("%d",&T);
	unsigned long long int A[T],B[T],x,y;
	for(i=0;i<T;i++)
	scanf("%d %d",&A[i],&B[i]);
	for(i=0;i<T;i++)
	{
		for(y=1;y<=A[i];y+=2)
		{
			

			if(B[i]%2==1||y==A[i])
			{
			printf("-1\n");
			break;
			}
			if((y^B[i])*y==A[i])
			{
				x=A[i]/y;
				printf("%d %d\n",x,y);
				break;
			}
			
		}
		
	}
}