//deo koda prepisan sa sajta https://www.geeksforgeeks.org/find-xor-of-two-number-without-using-xor-operator/
#include <iostream>
#include <cmath>
using namespace std;
int main(){
int y,res,c,T;
cin>>T;
long long a[T];
long long b[T];
for(int i=0; i<T; i++){
    cin >> a[i];
    cin >> b[i];
}
for(int i=0; i<T; i++){
    for(int x=2; x<=a[i]; x++){
        if(a[i]%x==0 && x%2==1){
            y=a[i]/x;
            res=(x | y) & (~x | ~y);
            if(res==b[i]){
                cout << x <<" "<< y<<endl;
                break;
        }
            else{
                cout<<"-1"<<endl;
                break;
            }
    }
}
}
return 0;
}