#include #include #include #define ll long long using namespace std; template void read(T &x) { x = 0; char c = getchar(); int f = 0; for (; !isdigit(c); c = getchar()) f |= c == '-'; for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ '0'); if (f) x = -x; } template void write(T x, char ed = '\n') { if (x < 0) putchar('-'), x = -x; static short st[30], tp; do st[++tp] = x % 10, x /= 10; while (x); while (tp) putchar(st[tp--] | '0'); putchar(ed); } int T; ll a, b; int main() { //freopen ("hs.in","r",stdin); for (read(T); T; --T) { read(a), read(b); if (a > b) swap(a, b); if (a == b && a >= 2) { write(2, ' '), write(a); continue; } ll mx = -1, mn = b; if (a * 2 <= b) mx = mn = b - a; for (ll l = 2, r;l <= a && l <= b; l = r + 1) { ll t1 = a / l, t2 = b / l; r = min(a / t1, b / t2); //printf ("l = %lld, r = %lld\n", l, r); //A - t1 * c = B - t2 * c if (t1 == t2) continue; ll tc = (a - b) / (t1 - t2); if (tc * (t1 - t2) != a - b || tc < l || tc > r) continue; if (tc > mx) mx = tc; if (tc < mn) mn = tc; } if (mx <= 1) write(-1, ' '), write(-1); else write(mn, ' '), write(mx); } return 0; }