#include using namespace std; using LL = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; while (T--) { LL a, b; cin >> a >> b; if (a > b) swap(a, b); LL d = b - a; if (d == 0) { if (a == 1) cout << "-1 -1" << std::endl; else { cout << "2 " << a << std::endl; } } else if (d == 1) { cout << "-1 -1" << std::endl; } else { LL x = d; if (d % 2 == 0) x = 2; else { for (LL i = 3; i * i <= d; ++i) { if (d % i == 0) { x = i; break; } } } cout << x << " " << d << std::endl; } } return 0; }