#include<bits/stdc++.h>
using namespace std;
int main(){
	long long t;
	cin>>t;
	long long a[t],b[t];
	for(long long i=0;i<t;i++)cin>>a[i]>>b[i];
	long long x,y;
	for(long long i=0;i<t;i++){
		x=(sqrt(b[i]*b[i]+4*a[i])+b[i])/2;
		y=a[i]/x;
		if(x*y!=a[i]){
            cout<<-1;
		}
		else cout<<x<<" "<<y<<endl;
	}
}