/* * Author: Kewth * Date: echo -n ' ' && date +%Y.%m.%d # Type "!!sh" in Vim. * Solution: To be updated after "Accept". * Digression: * CopyRight: __ __ __ __ | |/ |.-----.--.--.--.| |_| |--. | < | -__| | | || _| | |__|\__||_____|________||____|__|__| */ #include #include #define debug(...) fprintf(stderr, __VA_ARGS__) typedef long long ll; static struct { inline operator int () { int x; return scanf("%d", &x), x; } /* inline operator ll () { ll x; return scanf("%lld", &x), x; } */ /* template inline void operator () (T &x) { x = *this; } */ /* template inline void operator () (T &x, A &...a) */ /* { x = *this; this -> operator () (a...); } */ } read; int main () { int q = read; while (q --) { int a = read, b = read; a -= b; if (a < 0) a = -a; if (a == 0) { if (b == 1) puts("-1 -1"); else printf("%d %d\n", 2, b); goto END; } for (int x = 2; x <= a / x; x ++) if (a % x == 0) { printf("%d %d\n", x, a); goto END; } if (a == 1) puts("-1 -1"); else printf("%d %d\n", a, a); END:; } }