#include #include #include #include #include using namespace std; const int maxn = 500010, inf = 1e9 + 233; template inline void read(T &k) { int f = 1; k = 0; char c = getchar(); while (c < '0' || c > '9') c == '-' && (f = -1), c = getchar(); while (c <= '9' && c >= '0') k = k * 10 + c - '0', c = getchar(); k *= f; } void solve() { int a, b; read(a); read(b); if (a == b && (a != 1 || b != 1)) { printf("%d %d\n", 2, a); return; } int tmp = abs(b - a); int ans1 = -1, ans2 = -1; for (int i = 2; 1ll * i * i <= tmp; i++) if (tmp % i == 0) { ans1 = i; break; } if (ans1 == -1 && tmp > 1) ans1 = tmp; printf("%d %d\n", ans1, abs(b - a) > 1 ? abs(b - a) : -1); } int main() { int T; read(T); while (T--) solve(); }