#include<iostream>
#define MAX 10

using namespace std;

int main(void)
{
    unsigned long long niza[MAX],nizb[MAX],niza1[MAX],a;
    int n,f=-1;

    cin>>n;

   for(int j=0;j<n;++j){
        cin>>niza[j]>>nizb[j];
    for(int i=1;i<=niza[j]/2;i+=2){
        a=niza[j]/i;
       if(niza[j]%i == 0 && (a^i) == nizb[j]){
           niza1[j] = niza[j] / i;
           nizb[j] = i;
           break;
           }
       else continue;
        }
        continue;
   }


 for(int i=0;i<n;++i)
    if(niza1[i] == niza[i])
       cout<<f;
    else
       cout<<nizb[i]<<" "<<niza1[i]<<endl;

    return 0;
}