#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

void findXY(ll a, ll b) {

    // Check is it possible
    if (b % 2) {
        cout << -1 << endl;
        return;
    }

    vector<ll> res;
    vector<ll> pres;
    res.push_back(0LL);

    // shift each time
    for (ll bit = 1; a/bit >= bit; bit <<= 1) {

        swap(res, pres);

        // Create mask
        ll maska = bit | (bit-1);

        res.clear();

        for (auto prevx : pres) {

            ll prevy = (prevx^b) & maska;
            if ( (((prevx*prevy)^a) & maska) == 0)
                res.push_back(prevx);

            ll x = prevx | bit;
            ll y = (x^b) & maska;

            if ( (((x*y)^a) & maska) == 0)
                res.push_back(x);
        }
    } // end of "bit loop"

    swap(res, pres);

    // Test solution and print
    res.clear();
    for (auto testx : pres)
    {
        if (a/testx >= testx) {
            ll testy = b ^ testx;
            if (testx * testy == a) res.push_back(testx);

        }
    }

    // Printing
    if (res.empty()) {
        cout << -1 << endl;
        return;
    }

    ll tmpx = res[0];
    ll tmpy = a/tmpx;

    if (tmpx*tmpy == a && (tmpx^tmpy) == b)
        cout << tmpx << " " << tmpy << endl;
    else
        cout << -1 << endl;
}

int main()
{
    // Input
    ll t; cin >> t;

    ll a, b;
    while (t--) {
        cin >> a >> b;
        // Call function
        findXY(a, b);
    }
    return 0;
}