#include <iostream>
#include <math.h>

using namespace std;

int main()
{
    int T, c;
    cin>>T;
    unsigned long long* A=new unsigned long long[T];
    unsigned long long* B=new unsigned long long[T];
    for(int i=0; i<T; i++)
    {
        cin>>A[i];
        cin>>B[i];
    }

    for(int i=0; i<T; i++)
    {
        c=0;
        if(A[i]%2==0 || B[i]%2!=0)
        {
            cout<<-1;
            continue;
        }
        for(unsigned long long j=1; j<=sqrt(A[i]); j=j+2)
        {
            if(A[i]%j==0ULL && (((A[i]/j)^j)==B[i]))
            {
                c=1;
                cout<<j<<" "<<A[i]/j<<"\n";
                break;
            }
        }
        if(c==0)
            cout<<-1<<"\n";
    }
    return 0;
}