#include <bits/stdc++.h>
using namespace std;
unsigned long long a[10000], b[10000];
main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    for(int i=1; i<=t; i++)
        cin>>a[i]>>b[i];
    int k, n, p;
    for(int i=0; i<=t; i++)
    {
        n=sqrt(a[i]);
        for(int j=1; j<=n&&p==-1; j+=2)
        {
            if(a[i]%j==0)
            {
                k=a[i]/j;
                if((j^k)==b[i])
                {
                    p=1;
                    cout<<j<<" "<<k;
                }
            }
        }
        if(p==-1)
        {
            cout<<p;
        }
        else
            p=-1;
        cout<<"\n";
    }
}