#include <iostream>
#define ll long long
using namespace std;

ll najv(ll a, ll b)
{
    return (a>b) ? a : b;
}
int main()
{
    ios::sync_with_stdio(false);
    int t;
    cin>>t;
    ll a[t], b[t];
    ll niz[t*2];
    for(ll i=0; i<t*2; ++i)
    {
        cin>>niz[i];
    }
    for(int i=0; i<t*2; i+=2)
    {
        //cout<<"i: "<<i<<"\n";
        //ll x, y, veci=najv(niz[i], niz[i+1]);
        bool nasao=false;
        ll r1, r2;
        for(ll j=1; j*j<=niz[i]; ++j)
        {
            //cout<<"usao"<<endl;
            ll x,y;
            x=j;
            y=niz[i]/j;
            //cout<<"x: "<<x<<" y: "<<y<< "niz[i]: "<<niz[i]<<" niz[i+1]" <<niz[i+1]<<"\n";
            if((x^y)==niz[i+1])
            {
                nasao=true;
                //cout<<x<<" "<<y<<"\n";
                r1=x;
                r2=y;
                break;
            }
        }
        if(!nasao)
            cout<<"-1\n";
        else
            cout<<r1<<" "<<r2<<"\n";
    }
    return 0;
}