#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int t;
	cin>>t;
	long long a[t],b[t],x,y,k;
	for(int i=0;i<t;i++)
	{
		cin>>a[i];
		cin>>b[i];
	}
	for(int i=0;i<t;i++)
	{
		k=sqrt(pow(b[i],2)+4*a[i]);
		x=(k-b[i])/2;
		y=(k+b[i])/2;
		if(abs(x-y)==b[i] && x*y==a[i])
		{
			cout<<x<<" "<<y<<endl;
		}
		else cout<<"-1"<<endl;
	}
}