#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() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int u;
    scanf("%d", &u);
    while (u--) {
      int i, n, q;
      scanf("%d%d%d", &i, &n, &q);
      if (i == q) {
        printf("%d\n", n / 2);
      } else {
        printf("%d\n", n / 2 + n % 2);
      }
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xece(%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     11ef <main+0xcf>
lea    0xea8(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0xc(%rbp)
cmp    $0x0,%eax
je     11ea <main+0xca>
lea    0xe7e(%rip),%rdi
lea    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    11bf <main+0x9f>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe52(%rip),%rdi
call   1030 <printf@plt>
jmp    11e5 <main+0xc5>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
add    %edx,%esi
lea    0xe27(%rip),%rdi
call   1030 <printf@plt>
jmp    1167 <main+0x47>
jmp    1141 <main+0x21>
mov    -0x4(%rbp),%eax
add    $0x20,%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    0xecf(%rip),%rdi
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0x8(%rsp)
jae    1159 <main+0x39>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0x4(%rsp),%r15
lea    0xe9b(%rip),%r12
lea    0x14(%rsp),%r13
lea    0x10(%rsp),%rbx
lea    0xc(%rsp),%rbp
lea    0xe8c(%rip),%r14
jmp    1187 <main+0x67>
nopl   (%rax)
subl   $0x1,0x8(%rsp)
jb     1148 <main+0x28>
lea    0xe76(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,0x4(%rsp)
jb     1180 <main+0x60>
nop
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x14(%rsp),%eax
mov    0x10(%rsp),%esi
mov    %esi,%ecx
shr    $0x1f,%ecx
add    %esi,%ecx
mov    %ecx,%edx
and    $0xfffffffe,%edx
sub    %edx,%esi
sar    %ecx
add    %ecx,%esi
cmp    0xc(%rsp),%eax
cmove  %ecx,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
subl   $0x1,0x4(%rsp)
jae    11a0 <main+0x80>
jmp    1180 <main+0x60>

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

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