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

struct p {
    int i, x, y;

    p(int i, int x, int y) : i(i), x(x), y(y) {};
};

void solve(unsigned long long a, unsigned long long b) {
    unsigned long long x = 0, y = 0; // first bit is set
    int k = 0;

    unsigned long long bCopy = b;

    while (bCopy > 0) {
        bCopy >>= 1;
        if (bCopy == 0)
            break;
        k++;
    }
    x |= (1 << k);

    bool found = false;
    queue<p> solution;
    solution.push(p(0, x, y));

    while(!solution.empty()) {
        p cur = solution.front();

        //cout << cur.x << " " << cur.y << "\n";

        if (cur.x * cur.y > a)
            continue;
        if (cur.y * cur.y > a)
            continue;
        if (cur.i >= k) {
            if (cur.x * cur.y == a) {
                x = cur.x;
                y = cur.y;
                found = true;
                break;
            } else {
                break;
            }
        }

        int bit = 1 << (cur.i);

        if (b & bit) {
            // n-th bit in x and y is different

            solution.push(p(cur.i + 1, cur.x | bit, cur.y)); // 1 0
            solution.push(p(cur.i + 1, cur.x, cur.y | bit)); // 0 1
        } else {
            // n-th bit in x and y is the same

            solution.push(p(cur.i + 1, cur.x | bit, cur.y | bit)); // 1 1
            solution.push(p(cur.i + 1, cur.x, cur.y)); // 0 0
        }

        solution.pop();
    }

    if (found)
        cout << x << " " << y;
    else
        cout << "-1";
    return;
}

int main() {
    ios_base::sync_with_stdio(false);

    int k;
    cin >> k;

    for (int i = 0; i < k; i++) {
        unsigned long long x, y;

        cin >> x >> y;
        solve(x, y);
    }

    return 0;
}