#include <stdio.h>
#include <math.h>
main()
{
  int t,a,b,x=1,y;
  scanf("%d", &t);
  while(t>0)
  {
    scanf("%d %d", &a, &b);
    if(b==0)
    {
      if(sqrt(a)*sqrt(a)==a) printf("%.0f %.0f\n", sqrt(a),sqrt(a));
      else printf("-1\n");
    }
    else
    {
      while(x<=a/(b+1))
      {
        if(x*(x+b)==a)
        {
           printf("%d %d\n", x,x+b);
           break;
        }
        else x++;
      }
      if(x>a/(b+1)) printf("-1");
    } 
  }
}