#include <bits/stdc++.h>
#define mod 65536
 
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;
a1=a%mod;
b1=b%mod;
vector<long long> v;
for(i=0;i<mod;i++){
    if(a1==i*(i^b1)%mod) v.push_back(i);
}
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/mod;j++){
        long long tmp=j*mod+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;
    x=resi(a,b);
    if(x.first==-1) cout<<-1<<"\n";
    else cout<<x.first<<" "<<x.second<<"\n";
    }
    return 0;
}