#include <bits/stdc++.h>
#define mmod 1024
#define mod 524288
 
using namespace std;

int broj(long long a){
    int cnt=0;
    while(a){
        cnt++;
        a/=2;
    }
    return cnt;
}

pair <long long,long long> resi(long long a,long long b){
long long a1,b1,i,j,p,l;
a1=broj(a);
b1=broj(b);
p=min(a1/2+a1%2,a1-b1+1);
l=1;
for(i=0;i<p;i++) l*=2;
vector<long long> v,u;
a1=a%mmod;
b1=b%mmod;
for(i=0;i<mmod;i++){
    if(a1==i*(i^b1)%mmod) u.push_back(i);
}
a1=a%mod;
b1=b%mod;
for(i=0;i<mod/mmod;i++){
    for(j=0;j<u.size();j++){
    long long tmp=u[j]+i*mmod;
    if(a1==tmp*(tmp^b1)%mod) v.push_back(tmp);
    }
}
if(a1==a){
    if(v.size()) return {v[0],v[0]^b};
    else return {-1,-1};
}
for(i=0;i<v.size();i++){
    for(j=0;j<=l;j+=mod){
        long long tmp=j+v[i];
        if(tmp*(tmp^b)==a) return {tmp,tmp^b};
    }
}
return {-1,-1};
}
 
int main()
{
    srand(time(NULL));
    std::ios_base::sync_with_stdio(false);
    long long a,b;
    pair<long long,long long> x;
    int t;
    cin>>t;
    while(t--){
    cin>>a>>b;
    long long tmp,pom;
    //tmp=rand();
    //pom=rand();
    //a=tmp*pom;
    //b=tmp^pom;
    x=resi(a,b);
    if(x.first==-1) cout<<-1<<"\n";
    else cout<<x.first<<" "<<x.second<<"\n";
    }
    return 0;
}