#include <iostream>
#include <math.h>

using namespace std;

int main() {
    int t,p;
    cin >> t;
   
    unsigned long long a[t], b[t];
    unsigned long long x, y;
    
    for (int i= 0; i<t; i++) {
        cin>>a[i]>>b[i];
    }
    
    for (int j=0; j<t; j++) {
        for (y=1; y<=(floor(sqrt(a[j]))); y+=2) {
            p=-1;
            if(a[j]%y==0) {
               x=a[j]/y;
               if((x^y)==b[j]) {
                    cout<<x<<" "<<y<<"\n";
                    p=0;
                    break;
                }
            }
        }
        if (p==-1) {
            cout<<p<<"\n";
        }
    
    }
    return 0;
}