#include <bits/stdc++.h>

typedef long long ll;

using namespace std;


main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);


    int t; cin >> t;

    for (int i=0; i<t; i++)
    {

        ll a,b;
        cin >> a >> b;

        bool ind = false;

        for (int j=1; j<=sqrt(a); j++)
        {
        if ((a%j)==0)
        {
            int k= a/j;

            unsigned char temp1= k;
            unsigned char temp2= j;
            auto ispit=k^j;

            if (ispit==b) { cout << k << " " << j << "\n"; ind =true;}
            if (ind) break;
        }
         }
        if (ind==false) cout << "-1" << "\n";
    }




}