#include <math.h>
#include <iostream>


using namespace std;

int
main ()
{
  int T, P, I, J;
  cin >> T;

  unsigned long long A[T], B[T];
  unsigned long long X, Y;

  for (I = 0; I < T; I++)
    {
      cin >> A[I] >> B[I];
    }

  for (J = 0; J < T; J++)
    {
      for (Y = 1; Y <= (sqrt (A[J])); Y += 2)
	{
	  P = -1;
	  X = A[J] / Y;
	  if ((X * Y == A[J]) && ((X ^ Y) == B[J]))
	    {
	      cout << X << " " << Y << "\n";
	      P = 0;
	      break;
	    }
	}
      if (P == -1)
	{
	  cout << P << "\n";
	}

    }
  return 0;
}