#include <iostream>
#include <cmath>
using namespace std;

int main() {
 int t;
 cin >> t;
 unsigned long long int a[t],b[t],x[t],y[t];
 for (int i=0;i<t;i++){
   x[i]=0;
   y[i]=0;
 }
 for (int i=0;i<t;i++) {
   cin >> a[i] >>b[i];
   for (unsigned long long int j=1;j<a[i]/2;j+=2) {
     int d=0;
     if (a[i]%j==0) {
       d=a[i]/j;
       if ((j^d)==b[i]){
         x[i]=j;
         y[i]=d; 
       } 
     }
   }
 }
 for (int i=0;i<t;i++){
   if (x[i]!=0){
     cout<<x[i]<<" "<<y[i]<<endl;
   } else {
     cout<<-1<<endl;
   }   
 }
}