#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int t, ind;
    cin>>t;
    unsigned long long a, b, x, y;

    while(t--){
        cin>>a>>b;
        x=1;
        ind=0;
        while(x*x<=a){
            if(a%x==0){
                y=a/x;
                if((x^y)==b){
                    cout<<x<<' '<<y<<endl;
                    ind=1;
                    break;
                }
            }
            x+=2;
        }
        if(ind==0) cout<<-1<<endl;
    }
    return 0;
}