#include using namespace std; typedef long long ll; ll t = 1,n,m,k,q,l,r,a,b,c,u,v,x,y,z,mod = 1e9 + 7; string s; struct st{ll x,y; /*bool operator < (const st &a) const{return x < a.x;};*/}; bool cmp(const st &a,const st &b){return a.x < b.x;} inline ll read(){ ll s = 0,w = 1; char ch = getchar(); while (ch > '9' || ch < '0'){ if (ch == '-') w = -1; ch = getchar();} while (ch <= '9' && ch >= '0') s = (s << 1) + (s << 3) + (ch ^ 48),ch = getchar(); return s * w; } ll qp(ll x,ll y){ ll a = 1,b = x; while (y){ if (y & 1) a = a * b % mod; b = b * b % mod,y >>= 1; } return a; } ll get(ll x){ for (ll i = 2;i <= sqrt(x);i += 1) if (!(x % i)) return i; return x; } int main(){t = read(); while (t --){ n = read(),m = read(); ll qwq = abs(n - m); if (n == 1 && m == 1) printf("%lld %lld\n",-1ll,-1ll); else if (!qwq) printf("%lld %lld\n",2ll,n); else if (qwq == 1) printf("%lld %lld\n",-1ll,-1ll); else printf("%lld %lld\n",get(qwq),qwq); } return 0; }