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

void findValues(ll a, ll b)
{
    // base condition
    if ((b % 2)) {
        cout << "-1" << endl;
        return;
    }

    ll x;

    for (x = 1; x <= max(a, b); x += 2)
        if (((x ^ (max(a, b)/x)) == b) && x*(max(a, b)/x) == a) {
            cout << x << " " << max(a, b)/x << endl;
            return;
        }

    cout << "-1" << endl;
}

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

    ll a, b;
    while (t--) {
        cin >> a >> b;

        findValues(a, b);
    }
    return 0;
}