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