#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 GCD(long, long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, long *, ...);
int main() {
  long t, i, lcm, gcm, a, b;
  scanf("%ld", &t);
  for (i = 1; i <= t; i++) {
    scanf("%ld %ld", &a, &b);
    gcm = GCD(a, b);
    lcm = (a * b) / gcm;
    if (gcm == a && lcm == b)
      printf("%ld %ld\n", a, b);
    else
      printf("-1\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xebe(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movq   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     11fc <main+0xcc>
lea    0xe92(%rip),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x38(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1050 <GCD@plt>
mov    %rax,-0x28(%rbp)
mov    -0x30(%rbp),%rax
imul   -0x38(%rbp),%rax
cqto
idivq  -0x28(%rbp)
mov    %rax,-0x20(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jne    11d8 <main+0xa8>
mov    -0x20(%rbp),%rax
cmp    -0x38(%rbp),%rax
jne    11d8 <main+0xa8>
mov    -0x30(%rbp),%rsi
mov    -0x38(%rbp),%rdx
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11e6 <main+0xb6>
lea    0xe32(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11eb <main+0xbb>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1159 <main+0x29>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeaf(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpq   $0x0,0x10(%rsp)
jle    11db <main+0x9b>
lea    0xe90(%rip),%r14
lea    0x8(%rsp),%r15
mov    %rsp,%rbx
lea    0xe89(%rip),%r12
lea    0xe8b(%rip),%r13
xor    %ebp,%ebp
jmp    11a3 <main+0x63>
nopw   0x0(%rax,%rax,1)
mov    %r13,%rdi
call   1030 <puts@plt>
add    $0x1,%rbp
cmp    0x10(%rsp),%rbp
jge    11db <main+0x9b>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x8(%rsp),%rdi
mov    (%rsp),%rsi
call   1060 <GCD@plt>
cmp    0x8(%rsp),%rax
jne    1190 <main+0x50>
mov    (%rsp),%rdx
mov    %r12,%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1198 <main+0x58>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [8 x i8] c"%ld %ld\00"
@.str.2 = [9 x i8] c"%ld %ld\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 i64
%7 = alloca i64
store i32 0, i32* %1
%8 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
store i64 1, i64* %3
br label %9
9: ; preds = %37, %0
%10 = load i64, i64* %3
%11 = load i64, i64* %2
%12 = icmp sle i64 %10, %11
br i1 %12, label %13, label %40
13: ; preds = %9
%14 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i64* %6, i64* %7)
%15 = load i64, i64* %6
%16 = load i64, i64* %7
%17 = call i64 @GCD(i64 %15, i64 %16)
store i64 %17, i64* %5
%18 = load i64, i64* %6
%19 = load i64, i64* %7
%20 = mul nsw i64 %18, %19
%21 = load i64, i64* %5
%22 = sdiv i64 %20, %21
store i64 %22, i64* %4
%23 = load i64, i64* %5
%24 = load i64, i64* %6
%25 = icmp eq i64 %23, %24
br i1 %25, label %26, label %34
26: ; preds = %13
%27 = load i64, i64* %4
%28 = load i64, i64* %7
%29 = icmp eq i64 %27, %28
br i1 %29, label %30, label %34
30: ; preds = %26
%31 = load i64, i64* %6
%32 = load i64, i64* %7
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 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 %37
37: ; preds = %36
%38 = load i64, i64* %3
%39 = add nsw i64 %38, 1
store i64 %39, i64* %3
br label %9
40: ; preds = %9
ret i32 0
}

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