#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll t, a, b;
int main()
{
    cin >> t;
    while(t--)
    {
        cin >> a >> b;
        bool nasao=false;
        for(ll i=1;i*i<=a;i+=2)
        {
            if(a%i==0)if((i^(a/i))==b){cout << i << " " << a/i << endl; nasao=true; break;}
        }
        if(!nasao)cout << "-1" << endl;
    }
    return 0;
}