#include<iostream>
#include<cmath>
using namespace std;
void upiti(int t)
{
    unsigned long long int m,s,sk,x,a,b;
    for(int i=0;i<t;i++)
    {
        cin>>m>>x;
        sk=x*x+2*m;
        s=sqrt(sk+2*m);
        if (s==sqrt(sk+2*m)){
        a=(s-x)/2;
        b=m/a;
        cout<<a<<' '<<b;}
        else
            cout<<"-1"<<endl;
    }
}
int main()
{
    int t;
    cin>>t;
    upiti(t);
}