#include <bits/stdc++.h>


using namespace std;


void test(long long a, long long b)
{
    long long x;

    if(a>b) {
        if(b!=0 && b & 1 ==0) {
            cout << "-1" << endl;
            return;
        }
        unsigned int granica = (unsigned int) sqrt(a) + 1;
        for(unsigned int y=1;y<=granica;y++,y++) {
            x=b xor y;
            if(x*y==a) {
                cout<< x << " " << y << endl;
                return;
            }
        }
    }
    cout << "-1" << endl;
    return;
}

int main()
{

    ios::sync_with_stdio(false);

    int t;
    long long a,b;

    cin >> t;
    for(int i=0;i<t;i++) {
        cin >> a >> b;
        test(a,b);
    }

    return 0;
}