#include typedef long long LL; #define FOR(i, a, b) for (int i = (a), i##_END_ = (b); i <= i##_END_; ++i) #define DNF(i, a, b) for (int i = (a), i##_END_ = (b); i >= i##_END_; --i) template void in(Tp &x) { char ch = getchar(), f = 1; x = 0; while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar(); if (ch == '-') f = -1, ch = getchar(); while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); x *= f; } template bool chkmax(Tp &x, Tp y) {return x >= y ? 0 : (x=y, 1);} template bool chkmin(Tp &x, Tp y) {return x <= y ? 0 : (x=y, 1);} template Tp Max(const Tp &x, const Tp &y) {return x > y ? x : y;} template Tp Min(const Tp &x, const Tp &y) {return x < y ? x : y;} int T; void divide(int x) { if (x == 1) { puts("-1 -1"); return; } int t = int(sqrt(x)) + 1; int low = x; FOR(i, 2, t) { if (x % i == 0) { low = i; break; } } printf("%d %d\n", low, x); } int main() { in(T); while (T--) { int a, b; in(a); in(b); if (a == b && a != 1) { printf("2 %d\n", Max(a, b)); } else if (a == b && a == 1) { puts("-1 -1"); } else divide(Max(a, b) - Min(a, b)); } return 0; }