#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 combmod(long long, long long, long long);
int /*<<< orphan*/ printf(char *, long long);
int /*<<< orphan*/ scanf(char *, long long *, ...);
int main() {
  long long int a, b, c, i, j, k;
  scanf("%lld", &a);
  for (i = 1; i <= a; i++) {
    scanf("%lld %lld %lld", &b, &c, &k);
    j = combmod(b, c, k);
    printf("%lld\n", j);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec4(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
movq   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     11b7 <main+0x87>
lea    0xe92(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
lea    -0x38(%rbp),%rcx
mov    $0x0,%al
call   1050 <scanf@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x38(%rbp),%rdx
call   1040 <combmod@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rsi
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%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    $0x28,%rsp
lea    0xec5(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmpq   $0x0,0x8(%rsp)
jle    11bd <main+0x8d>
lea    0xea0(%rip),%r14
lea    0x20(%rsp),%r15
lea    0x18(%rsp),%r12
lea    0x10(%rsp),%r13
lea    0xe99(%rip),%rbx
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
mov    %r13,%rcx
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x20(%rsp),%rdi
mov    0x18(%rsp),%rsi
mov    0x10(%rsp),%rdx
call   1040 <combmod@plt>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    0x8(%rsp),%rbp
jl     1180 <main+0x50>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [15 x i8] c"%lld %lld %lld\00"
@.str.2 = [6 x i8] c"%lld\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 ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i64* %2)
store i64 1, i64* %5
br label %9
9: ; preds = %21, %0
%10 = load i64, i64* %5
%11 = load i64, i64* %2
%12 = icmp sle i64 %10, %11
br i1 %12, label %13, label %24
13: ; preds = %9
%14 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64* %3, i64* %4, i64* %7)
%15 = load i64, i64* %3
%16 = load i64, i64* %4
%17 = load i64, i64* %7
%18 = call i64 @combmod(i64 %15, i64 %16, i64 %17)
store i64 %18, i64* %6
%19 = load i64, i64* %6
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %19)
br label %21
21: ; preds = %13
%22 = load i64, i64* %5
%23 = add nsw i64 %22, 1
store i64 %23, i64* %5
br label %9
24: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%lld\00"
@.str.1 = [15 x i8] c"%lld %lld %lld\00"
@.str.2 = [6 x i8] c"%lld\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 = icmp slt i64 %10, 1
br i1 %11, label %23, label %12
12: ; preds = %0, %12
%13 = phi i64 [ %20, %12 ], [ 1, %0 ]
%14 = call i32 (i8*, i64*, ...) @scanf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i64* %2, i64* %3, i64* %4)
%15 = load i64, i64* %2
%16 = load i64, i64* %3
%17 = load i64, i64* %4
%18 = call i64 @combmod(i64 %15, i64 %16, i64 %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i64 %18)
%20 = add nuw nsw i64 %13, 1
%21 = load i64, i64* %1
%22 = icmp slt i64 %13, %21
br i1 %22, label %12, label %23
23: ; preds = %12, %0
ret i32 0
}