#include #include #include #include #include #define mod 998244353 using namespace std; typedef long long ll; void checkmn(ll a, ll b, ll c, ll &mn) { if(a % c == b % c && c > 1 && (mn == -1 || mn > c)) mn = c; } void checkmx(ll a, ll b, ll c, ll &mx) { if(a % c == b % c && c > 1 && (mx == -1 || mx < c)) mx = c; } ll min_factor(ll x) { for(int i = 2; i <= 100000; i++) if(x % i == 0) return i; return x; } void solve() { ll a, b; scanf("%lld%lld", &a, &b); ll d = (a > b) ? a - b : b - a; if(d == 1 || d == 0 && a == 1) puts("-1 -1"); else if(d == 0) printf("2 %lld\n", a); else printf("%lld %lld\n", min_factor(d), d); } int main() { int T; scanf("%d", &T); while(T--) { solve(); } }