#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;
    t*=2;
    ll niz[t];
    for(ll i=0; i<t; ++i)
    {
        cin>>niz[i];
    }
    for(int i=0; i<t; i+=2)
    {
        //cout<<"i: "<<i<<"\n";
        ll x, y, veci=najv(niz[i], niz[i+1]);
        bool nasao=false;
        for(ll j=0; j<=veci; ++j)
        {
            for(ll k=0; k<=veci; ++k)
            {
                //cout<<"A: "<<niz[i]<<" B: "<<niz[i+1]<<"\n";
                //cout<<"j*k: "<<j*k<<" j^k: "<<(j^k)<<"\n";
                if(niz[i]==j*k && niz[i+1]==(j^k))
                {
                    //<<x<<" "<<y<<"\n";
                    x=j;
                    y=k;
                    nasao=true;
                    break;
                }
                //cout<<"\n";
            }
            if(nasao)
                break;
        }
        if(!nasao)
            cout<<"-1\n";
        else
            cout<<x<<" "<<y<<"\n";
    }
    return 0;
}