#include <bits/stdc++.h>
using namespace std;
int t, x, y, res;
int main() {
cin >> t;
while (t--) {
cin >> x >> y;

for (int i = 1; i <= x; i++) {
    for (int j = x; j>=1; j--) {
        if (i*j == x and i^j==y) {
            cout << i << " " << j << endl;
            break;
        }
        else {
            printf("-1\n");
            break;
        }
    }
    break;
}
}


return 0;
}