#include using namespace std; typedef long long ll; typedef unsigned long long ull; typedef double db; typedef pair Pii; #define reg register #define mp make_pair #define pb push_back #define Mod1(x) ((x>=P)&&(x-=P)) #define Mod2(x) ((x<0)&&(x+=P)) #define rep(i,a,b) for(int i=a,i##end=b;i<=i##end;++i) #define drep(i,a,b) for(int i=a,i##end=b;i>=i##end;--i) template inline void cmin(T &a,T b){ ((a>b)&&(a=b)); } template inline void cmax(T &a,T b){ ((a T rd(){ T s=0; int f=0; while(!isdigit(IO=getchar())) f|=IO=='-'; do s=(s<<1)+(s<<3)+(IO^'0'); while(isdigit(IO=getchar())); return f?-s:s; } bool Mbe; const int N=1e6+10,INF=1e9+10,P=998244353; int a,b,c,L,R; void Check(int m){ if(m>1 && m<=max(a,b) && a%m==b%m) cmax(R,m),cmin(L,m); } bool Med; int main(){ rep(_,1,rd()) { a=rd(),b=rd(),c=abs(a-b); if(a==b) { if(a==1) puts("-1 -1"); else printf("2 %d\n",a); continue; } L=1e9,R=-1; rep(i,1,sqrt(c)+10) if(c%i==0) Check(i),Check(c/i); if(R==-1) puts("-1 -1"); else printf("%d %d\n",L,R); } }