#include using namespace std; int t, a, b, s; int read() { int x = 0, p = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') p = -1; for (; isdigit(c); c = getchar()) x = (x << 3) + (x << 1) + (c & 15); return x * p; } int main() { t = read(); while (t--) { a = read(); b = read(); s = abs(a - b); if (s == 0) { if (a == 1) puts("-1 -1"); else cout << 2 << ' ' << a << endl; continue; } if (s == 1) { puts("-1 -1"); continue; } for (int i = 2; i <= s; i++) { if (i * i > s) { cout << s << ' '; break; } if (s % i) continue; cout << i << ' '; break; } cout << s << endl; } return 0; }