#include using namespace std; #ifdef tabr #include "library/debug.cpp" #else #define debug(...) #endif int main() { ios::sync_with_stdio(false); cin.tie(0); int tt; cin >> tt; while (tt--) { int a, b; cin >> a >> b; if (a > b) { swap(a, b); } if (b - a == 1 || b == 1) { cout << -1 << " " << -1 << '\n'; continue; } int c = b - a; if (c == 0) { cout << 2 << " " << a << '\n'; continue; } int d = c; for (int i = 2; i * i <= c; i++) { if (c % i == 0) { d = i; break; } } cout << d << " " << c << '\n'; } return 0; }