#include #include #include #include #include #include #include #include #include #define X first #define Y second #define PB push_back #define MP make_pair #define EB emplace_back #define mset(var,val) memset(var,val,sizeof(var)) #define IOS ios::sync_with_stdio(false);cin.tie(0) #define rep(i,n) for(int i = 0; i < n; ++i) #define rep1(i,n) for(int i = 1; i <= n; ++i) using namespace std; typedef long long ll; #ifdef local #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0) void err() { cout << endl; } template class T, typename t, typename... Args> void err(T a, Args... args) { for (auto x: a) cout << x << ' '; err(args...); } template void err(T a, Args... args) { cout << a << ' '; err(args...); } #else #define dbg(...) #endif typedef pair pii; const int inf = 0x3f3f3f3f; const long long INF = 0x3f3f3f3f3f3f3f3fLL; const double PI = acos(-1.0); const double eps = 1e-8; //const int mod=1e9+7; const int N = 1e5+5; const int M = N*100; const int maxn=1e7+50; ll gcd(ll a, ll b) { return a%b?gcd(b,a%b):b; } void work() { ll a,b; cin >> a >> b; if (a < b) swap(a,b); if (a == b) { if (a == 1) { cout << -1 << " " << -1 << "\n"; return; } cout << 2 << " " << max(a,2ll) << "\n"; return; } ll x = a - b; if (x != 1) { ll y = x; for (ll i = 2; i <= sqrt(x+1); ++i) { if (x%i==0) { y = i; break; } } cout << y << " " << x << "\n"; } else { cout << -1 << " " << -1 << "\n"; } } int main() { #ifdef local freopen("in.txt","r",stdin); // freopen("out.txt","w",stdout); #endif // local IOS; // init(); int t; cin>>t; while(t--) work(); return 0; }