#include <bits/stdc++.h>

using namespace std;
int T;
long long A,B;
bool m;
int main()
{
    cin >> T;
    for(int  i = 0; i < T; i++){
        cin >> A >> B;
        m = false;
        for(int j = 1; j <= sqrt(A); j+=2){
            if((j ^ (A/j)) == B){
                cout << j << " " << A/j;
                m = true;
                break;
            }
        }
        if(!m)
            cout << -1;
        cout << "\n";
    }
    return 0;
}