#include <iostream>
#include <cmath>
#include<cstdio>
#include<algorithm>
#include<iomanip>
using namespace std;
int a,b,t;
float x,y;
int main() {
cin>>t;

for(int i=1; i<=t; t++) {
    cin>>a;
    cin>>b;
}

for(int i=1; i<=t; t++) {
    y=(b+sqrt(b*b+4*a))/2;

  if(b>y or b==y) {
    y=(b-sqrt(b*b+4*a))/2;
        if(b>y or b==y or y<0 or y==0) {
            cout<<-1;
        }
        else {
            x=y-b;
        }
  }
  else {
    x=y-b;
  }
}

for(int i=1; i<=t; t++) {

    if(y%1.0!=0 or x%1.0!=0) {
        cout<<-1;
    }
    else {
       cout<<x<<" "<<y<<endl;
    }
}


return 0;
}