#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
long long gcd(long long, long long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  long long int g, l, gc, lc;
  int i, t;
  scanf("%d", &t);
  while (t--) {
    scanf("%lld %lld", &g, &l);
    gc = gcd(g, l);
    lc = (g * l) / gc;
    if (gc == g && lc == l)
      printf("%lld %lld\n", gc, lc);
    else
      printf("-1\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    -0x30(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x30(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x30(%rbp)
cmp    $0x0,%eax
je     11e9 <main+0xb9>
lea    0xe97(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <gcd@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
imul   -0x18(%rbp),%rax
cqto
idivq  -0x20(%rbp)
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jne    11d6 <main+0xa6>
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    11d6 <main+0xa6>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e4 <main+0xb4>
lea    0xe3b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1151 <main+0x21>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xeac(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
subl   $0x1,0xc(%rsp)
jb     1212 <main+0xd2>
lea    0xe91(%rip),%r14
lea    0x18(%rsp),%r15
lea    0x10(%rsp),%rbx
lea    0xe8a(%rip),%r12
lea    0xe8e(%rip),%r13
jmp    119f <main+0x5f>
nopl   0x0(%rax)
mov    %r13,%rdi
call   1030 <puts@plt>
subl   $0x1,0xc(%rsp)
jb     1212 <main+0xd2>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x18(%rsp),%rdi
mov    0x10(%rsp),%rsi
call   1060 <gcd@plt>
mov    %rax,%rsi
mov    0x18(%rsp),%rdi
mov    0x10(%rsp),%rcx
mov    %rcx,%rax
imul   %rdi,%rax
mov    %rax,%rdx
or     %rsi,%rdx
shr    $0x20,%rdx
je     11f0 <main+0xb0>
cqto
idiv   %rsi
cmp    %rdi,%rsi
je     11f9 <main+0xb9>
jmp    1190 <main+0x50>
nopw   0x0(%rax,%rax,1)
xor    %edx,%edx
div    %esi
cmp    %rdi,%rsi
jne    1190 <main+0x50>
cmp    %rcx,%rax
jne    1190 <main+0x50>
mov    %r12,%rdi
mov    %rcx,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
subl   $0x1,0xc(%rsp)
jae    119f <main+0x5f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [10 x i8] c"%lld %lld\00"
@.str.2 = [11 x i8] c"%lld %lld\0A\00"
@.str.3 = [4 x i8] c"-1\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
br label %9
9: ; preds = %36, %0
%10 = load i32, i32* %7
%11 = add nsw i32 %10, -1
store i32 %11, i32* %7
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %37
13: ; preds = %9
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %3)
%15 = load i64, i64* %2
%16 = load i64, i64* %3
%17 = call i64 @gcd(i64 %15, i64 %16)
store i64 %17, i64* %4
%18 = load i64, i64* %2
%19 = load i64, i64* %3
%20 = mul nsw i64 %18, %19
%21 = load i64, i64* %4
%22 = sdiv i64 %20, %21
store i64 %22, i64* %5
%23 = load i64, i64* %4
%24 = load i64, i64* %2
%25 = icmp eq i64 %23, %24
br i1 %25, label %26, label %34
26: ; preds = %13
%27 = load i64, i64* %5
%28 = load i64, i64* %3
%29 = icmp eq i64 %27, %28
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load i64, i64* %4
%32 = load i64, i64* %5
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 %31, i64 %32)
br label %36
34: ; preds = %26, %13
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %36
36: ; preds = %34, %30
br label %9
37: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [10 x i8] c"%lld %lld\00"
@.str.2 = [11 x i8] c"%lld %lld\0A\00"
@str = [3 x i8] c"-1\00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64
%3 = alloca i32
%4 = bitcast i64* %1 to i8*
%5 = bitcast i64* %2 to i8*
%6 = bitcast i32* %3 to i8*
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = add nsw i32 %8, -1
store i32 %9, i32* %3
%10 = icmp eq i32 %8, 0
br i1 %10, label %31, label %11
11: ; preds = %0, %27
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i64* %1, i64* %2)
%13 = load i64, i64* %1
%14 = load i64, i64* %2
%15 = call i64 @gcd(i64 %13, i64 %14)
%16 = load i64, i64* %1
%17 = load i64, i64* %2
%18 = mul nsw i64 %17, %16
%19 = sdiv i64 %18, %15
%20 = icmp eq i64 %15, %16
%21 = icmp eq i64 %19, %17
%22 = select i1 %20, i1 %21, i1 false
br i1 %22, label %23, label %25
23: ; preds = %11
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i64 %15, i64 %17)
br label %27
25: ; preds = %11
%26 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
br label %27
27: ; preds = %25, %23
%28 = load i32, i32* %3
%29 = add nsw i32 %28, -1
store i32 %29, i32* %3
%30 = icmp eq i32 %28, 0
br i1 %30, label %31, label %11
31: ; preds = %27, %0
ret i32 0
}