#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ll;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    ll q;

    cin >> q;

    while(q--)
    {
        ll a, b;

        cin >> a >> b;

        ll low = 0, high = a, mid = 0;
        bool ispis = false;

        while(true)
        {
            if(mid == (low+high)/2)
            {
                low = high;
            }

            mid = (low+high)/2;
            ll x = b ^ mid;

            if(x*mid == a)
            {
                cout << x << " " << mid << "\n";
                ispis = true;
                break;
            }
            else if(x*mid > a)
            {
                high = mid;
            }
            else if(x*mid < a)
            {
                low = mid;
            }

            if(low == high)
            {
                break;
            }

        }

        if(!ispis)
        {
            cout << "-1\n";
        }
    }
}