#include #include using namespace std; void solve() { int a, b; cin >> a >> b; if (a == b) { if (a == 1) cout << "-1 -1\n"; else cout << "2 " << a << "\n"; } else { if (a < b) swap(a, b); int mx = a - b; if (mx < 2) { cout << "-1 -1\n"; return; } int mn; int sq = sqrt(mx); for (mn = 2; mn <= sq; mn++) { if (mx % mn == 0) { break; } } if (mn > sq) { mn = mx; } cout << mn << " " << mx << "\n"; } } int main() { int T; cin >> T; while (T--) solve(); return 0; }