#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 */
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main(void) {
  int t;
  int a, b, m, n;
  scanf("%d", &t);
  while (t--) {
    scanf("%d %d", &a, &b);
    m = a;
    n = b;
    while (n) {
      m = m % n;
      m ^= n ^= m ^= n;
    }
    n = a * b / m;
    printf("%d\n", n / m);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xecd(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11cd <main+0xad>
lea    0xea4(%rip),%rdi
lea    -0xc(%rbp),%rsi
lea    -0x10(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     11a5 <main+0x85>
mov    -0x14(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x18(%rbp),%eax
xor    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
xor    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
xor    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    1177 <main+0x57>
mov    -0xc(%rbp),%eax
imul   -0x10(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,%esi
lea    0xe43(%rip),%rdi
call   1030 <printf@plt>
jmp    1141 <main+0x21>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xed1(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0xc(%rsp)
jae    1153 <main+0x33>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
lea    0xea6(%rip),%r14
lea    0x14(%rsp),%r15
lea    0x10(%rsp),%r12
lea    0xe9b(%rip),%rbx
jmp    118c <main+0x6c>
nopl   (%rax)
imul   %esi,%ecx
mov    %ecx,%eax
cltd
idiv   %edi
cltd
idiv   %edi
mov    %rbx,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
subl   $0x1,0xc(%rsp)
jb     1145 <main+0x25>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%ecx
mov    %esi,%edi
test   %ecx,%ecx
je     1170 <main+0x50>
mov    %ecx,%edx
mov    %esi,%eax
xchg   %ax,%ax
mov    %edx,%edi
cltd
idiv   %edi
mov    %edi,%eax
test   %edx,%edx
jne    11b0 <main+0x90>
jmp    1170 <main+0x50>

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

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