#include using namespace std; typedef long long ll; typedef pair PII; const int N = 1e5 + 5, mod = 1e9 + 7; int T, a, b; int get(int x) { int res = x; for(int i = 2; i <= x / i; i++) { if(x % i == 0) { res = min(res, i); break; } } return res; } int main() { ios::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin >> T; while(T--) { cin >> a >> b; int c1 = 0, c2 = 0; if(a > b) swap(a, b); int c = b - a; if(!c) { c2 = a, c1 = 2; if(a == 1) c1 = c2 = -1; } else if(c == 1) c1 = c2 = -1; else c2 = c, c1 = get(c); cout << c1 << ' ' << c2 << endl; } return 0; }