#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 *, unsigned long long);
int /*<<< orphan*/ scanf(char *, unsigned long long *, ...);
int main() {
  unsigned long long t, n, i, a, b, fa, fb;
  scanf("%llu", &t);
  while (t--) {
    scanf("%llu%llu%llu", &a, &b, &n);
    unsigned long long fac = 2;
    if (n % 2 == 1) {
      fac = 2;
    } else {
      fac = 1;
    }
    a = fac * a;
    if (a > b) {
      printf("%llu\n", a / b);
    } else {
      printf("%llu\n", b / a);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x10(%rbp)
cmp    $0x0,%rax
je     11fe <main+0xde>
lea    0xe9f(%rip),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
lea    -0x18(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
movq   $0x2,-0x48(%rbp)
mov    -0x18(%rbp),%rax
and    $0x1,%rax
cmp    $0x1,%rax
jne    119b <main+0x7b>
movq   $0x2,-0x48(%rbp)
jmp    11a3 <main+0x83>
movq   $0x1,-0x48(%rbp)
mov    -0x48(%rbp),%rax
imul   -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jbe    11de <main+0xbe>
mov    -0x28(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x30(%rbp)
mov    %rax,%rsi
lea    0xe39(%rip),%rdi
call   1030 <printf@plt>
jmp    11f9 <main+0xd9>
mov    -0x30(%rbp),%rax
xor    %ecx,%ecx
mov    %ecx,%edx
divq   -0x28(%rbp)
mov    %rax,%rsi
lea    0xe19(%rip),%rdi
call   1030 <printf@plt>
jmp    1141 <main+0x21>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x20,%rsp
lea    0xed4(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subq   $0x1,0x8(%rsp)
jae    1158 <main+0x38>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xea1(%rip),%r14
mov    %rsp,%r15
lea    0x10(%rsp),%r12
lea    0x18(%rsp),%r13
lea    0xe9a(%rip),%rbx
jmp    11a7 <main+0x87>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rsi,%rax
or     %rcx,%rax
shr    $0x20,%rax
je     11ef <main+0xcf>
mov    %rsi,%rax
xor    %edx,%edx
div    %rcx
mov    %rax,%rsi
mov    %rbx,%rdi
call   1030 <printf@plt>
subq   $0x1,0x8(%rsp)
jb     1148 <main+0x28>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x18(%rsp),%rcx
and    $0x1,%ecx
add    $0x1,%rcx
imul   (%rsp),%rcx
mov    %rcx,(%rsp)
mov    0x10(%rsp),%rsi
cmp    %rsi,%rcx
jbe    1180 <main+0x60>
mov    %rcx,%rax
or     %rsi,%rax
shr    $0x20,%rax
je     11f9 <main+0xd9>
mov    %rcx,%rax
xor    %edx,%edx
div    %rsi
jmp    1194 <main+0x74>
mov    %esi,%eax
xor    %edx,%edx
div    %ecx
mov    %eax,%esi
jmp    1197 <main+0x77>
mov    %ecx,%eax
xor    %edx,%edx
div    %esi
mov    %eax,%esi
jmp    1197 <main+0x77>

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

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