#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{int br,i,t;
long j,c;
scanf("%i",&t);
long a[t],b[t];
for(i=0;i<t;i++){
do
scanf("%li",&a[i]);
while(a[i]%2==0);
scanf("%li",&b[i]);
}
for(i=0;i<t;i++){
j=1;
br=0;
while(j<=(sqrt(a[i]))&&br==0){

        c=(a[i]/j)^j;
        if(c==b[i]){
        printf("%li   %li\n",(a[i]/j),j);
        br++;}

      j++;

}
if(br==0)
    printf("%i\n",-1);
}


    return 0;
}