#include <cmath>
#include <cstdio>


int main()
{
	using u64 = unsigned long long;
	using u32 = unsigned int;

	u32 t;
	std::scanf("%u", &t);

	u64 parovi[20'000];

	for (u32 i = 0; i < t; ++i)
		std::scanf("%llu %llu", &parovi[i * 2], &parovi[i * 2 + 1]);

	for (u32 i = 0; i < t; ++i)
	{
		u64& a = parovi[i * 2];
		u64& b = parovi[i * 2 + 1];
		
		if ((b & 1))
		{
			std::puts("-1");
			continue;
		}

		u64 root = static_cast<u64>(std::sqrt(a)) + 1;
		u64 x, y;
		bool f = false;
		//std::printf("%llu\n", root);

		for (y = 1; y < root; y += 2)
		{
			if (!(a % y))
			{
				x = a / y;
				if ((x ^ y) == b)
				{
					f = true;
					std::printf("%llu %llu\n", x, y);
					break;
				}
			}
		}

		if (!f)
			std::puts("-1");
	}
}