#include #define ll long long #define uint unsigned int #define ull unsigned long long #define inf 1010000000 #define infll 1010000000000000000ll #define vi vector #define vll vector #define pb push_back #define pii pair #define pll pair #define pdd pair #define mpr make_pair #define fi first #define se second #define pq priority_queue #define pqll priority_queue #define up(x,y) (x<(y)?x=(y):0) #define dn(x,y) (x>(y)?x=(y):0) #define ad(x,y) (x=(x+(y))%mod) #define cbn(x,y) ((ll)fac[x]*inv[y]%mod*inv[(x)-(y)]%mod) using namespace std; int read(); ll readll(); int main(){ int cas = read(); while (cas--){ int x = read(), y = read(); if (x > y) swap(x, y); if (x == y){ if (y == 1){ puts("-1 -1"); continue; } printf("%d %d\n", 2, y); continue; } else y -= x; if (y == 1){ puts("-1 -1"); continue; } int t = 2; for (; t * t <= y; t++) if (!(y%t)) break; if (t * t <= y) printf("%d %d\n", t, y); else printf("%d %d\n", y, y); } return 0; } int read(){ int x=0; char ch=getchar(); bool flag=0; while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); } while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); } return flag?-x:x; } ll readll(){ ll x=0; char ch=getchar(); bool flag=0; while (ch<'0' || ch>'9'){ if (ch=='-') flag=1; ch=getchar(); } while (ch>='0' && ch<='9'){ x=x*10+ch-'0'; ch=getchar(); } return flag?-x:x; }