#include using namespace std; int main() { int T; cin>> T; while(T--) { int a, b; cin>> a>>b; if(a < b) swap(a,b); if (a==1) printf("-1 -1\n"); else if(a - b == 0) printf("%d %d\n", 2, a); else if(a - b == 1) printf("-1 -1\n"); else { int sub = a - b; int min_num = sub; for (int i=2;i*i <=sub; i++) if ((sub %i) ==0 ) { min_num = i; break; } printf("%d %d\n", min_num, sub); } } return 0; }