#include <bits/stdc++.h>

#define ll long long

using namespace std;

void solve() {

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

    if(b & 1) {
        cout << "-1" << endl;
        return;
    }

    ll n = round(sqrt(a));
    for(ll x = 1; x <= n; x += 2) {
        if(a % x == 0) {
            ll y = a / x;

            if((x ^ y) == b) {
                cout << x << " " << y << endl;
                return;
            }
        }
    }

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

int main() {

    int t;
    cin >> t;

    while(t--)
        solve();

    return 0;
}