#include <bits/stdc++.h>
using namespace std;
int main(){
    int t;
    cin>>t;

    while(t--){
        long long a,b;
        cin>>a>>b;
        bool x=0;
        for(int i=1;i*i<=a;i=i+2){
            if(a%i==0&&((i^(a/i))==b)){
                cout<<i<<' '<<a/i<<endl;
                x=1;
                break;
            }
        }
        if(x==0)cout<<-1<<endl;

    }

}