#include using namespace std; int main(void) { int T; scanf("%d", &T); while (T--) { int a, b; scanf("%d%d", &a, &b); if (a == b && a >= 2) { printf("%d %d\n", 2, a); continue; } int d = max(a, b) - min(a, b); int mn = (int)1e9+10, mx = 0; for (int i=1; i*i<=d; i++) if (d % i == 0) { if (i > 1 && a % i == b % i) mn = min(mn, i), mx = max(mx, i); if (d/i > 1 && a % (d/i) == b % (d/i)) mn = min(mn, d/i), mx = max(mx, d/i); } if (mn <= mx) printf("%d %d\n", mn, mx); else printf("-1 -1\n"); } return 0; } // a = xc + r // b = yc + r // c | b - a