#include using namespace std; #define rep(i,a,n) for (int i=a;i=a;i--) #define pb push_back #define mp make_pair #define all(x) (x).begin(),(x).end() #define fi first #define se second #define SZ(x) ((int)(x).size()) typedef vector VI; typedef long long ll; typedef pair PII; typedef double db; mt19937 mrand(random_device{}()); const ll mod=1000000007; int rnd(int x) { return mrand() % x;} ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;} ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;} // head int main() { int T; scanf("%d", &T); while(T--) { int a, b; scanf("%d%d", &a, &b); int d = max(a, b)-min(a, b); if(d==0) { if(a==1) printf("-1 -1\n"); else printf("2 %d\n", a); continue; } if(d==1) { printf("-1 -1\n"); continue; } int mn = 0; for(int i=2; i*i<=d; i++) { if(d%i==0) { mn = i; break; } } if(!mn) mn = d; printf("%d %d\n", mn, d); } return 0; }