#include<iostream>
using namespace std;

typedef unsigned long long ll;

ll a, b, i;
int q;
int main() {
	cin >> q;
	while (q--) {
		cin >> a >> b;
		for (i = 1; i * i <= a; i += 2) {
			if (i * (a / i) == a && (i ^ (a / i)) == b) {
				break;
			}
		}
		if (i * i > a) {
			cout << -1;
		}
		else {
			cout << i << ' ' << a / i << '\n';
		}
	}

}