#include using namespace std; const int inf = 1e9; int T, a, b; int main() { scanf("%d", &T); while (T--) { scanf("%d%d", &a, &b); int w = abs(a - b); if (w == 0) { if (max(a, b) == 1) printf("-1 -1\n"); else printf("%d %d\n", 2, max(a, b)); } else if (w == 1) printf("-1 -1\n"); else { int mn = w, mx = w; for (int i = 2; i * i <= w; ++i) if (w % i == 0) { mn = i; break; } printf("%d %d\n", mn, mx); } } }