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


int main()
{
    long long unsigned t,a,b;
    int s=0;
    scanf("%llu",&t);
    for(long long unsigned i=0;i<t;i++){
        scanf("%llu %llu",&a,&b);
        if(b&1){printf("-1\n");continue;}
        for(long long unsigned j=1;j<=a;j+=2){
            if(j*(j^b)==a){
                printf("%llu %llu\n",j,j^b);s=1;break;
            }

        }
        if(s==0){printf("-1\n");}
        s=0;
    }

    return 0;
}