#include <bits/stdc++.h>
 
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=1,mod=2;
a1=broj(a);
b1=broj(b);
p=min(a1/2+a1%2,a1-b1+1);
vector<long long> v,u;
u.push_back(0);
for(i=1;i<=p;i++){
a1=a%mod;
b1=b%mod;
for(j=0;j<u.size();j++){
	long long tmp=u[j];
	if(a1==tmp*(tmp^b1)%mod) v.push_back(tmp);
	tmp=u[j]+l;
	if(a1==tmp*(tmp^b1)%mod) v.push_back(tmp);
}
u.clear();
u=v;
v.clear();
l*=2;
mod*=2;
}
v=u;
for(i=0;i<v.size();i++){
	if(a==v[i]*(v[i]^b)) return {v[i],v[i]^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;
}