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

ll a,b;

void resi(){
    cin >> a >> b;
    for(ll i = 1; i*i <= a; i++){
        if(a%i){
            continue;
        }
        ll x = i,y = a/i;
        if((x^y) == b){
            cout << x << " " << y << endl;
            return;
        }
    }
    cout << -1 << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t;
    cin >> t;
    while(t--){
        resi();
    }
}