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


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     11f4 <main+0xd4>
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     11ef <main+0xcf>
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
add    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    11cb <main+0xab>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe46(%rip),%rdi
call   1030 <printf@plt>
jmp    11ea <main+0xca>
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
sub    %eax,%esi
lea    0xe22(%rip),%rdi
call   1030 <printf@plt>
jmp    1167 <main+0x47>
jmp    1141 <main+0x21>
xor    %eax,%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>
jmp    11b3 <main+0x93>
nopw   0x0(%rax,%rax,1)
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
sub    %ecx,%esi
mov    %r14,%rdi
call   1030 <printf@plt>
subl   $0x1,0x4(%rsp)
jb     1180 <main+0x60>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
mov    %rbp,%rcx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%ecx
add    %esi,%ecx
add    0xc(%rsp),%ecx
lea    0x1(%rsi),%eax
test   $0x1,%cl
jne    11a0 <main+0x80>
mov    %eax,%esi
shr    $0x1f,%esi
add    %eax,%esi
sar    %esi
jmp    11ab <main+0x8b>

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 = %40, %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 %41
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 = %39, %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 %40
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* %5
%22 = add nsw i32 %20, %21
%23 = load i32, i32* %6
%24 = add nsw i32 %22, %23
%25 = and i32 %24, 1
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %18
%28 = load i32, i32* %5
%29 = add nsw i32 %28, 1
%30 = sdiv i32 %29, 2
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %39
32: ; preds = %18
%33 = load i32, i32* %5
%34 = load i32, i32* %5
%35 = add nsw i32 %34, 1
%36 = sdiv i32 %35, 2
%37 = sub nsw i32 %33, %36
%38 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %32, %27
br label %14
40: ; preds = %14
br label %8
41: ; preds = %8
ret i32 0
}

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 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
%13 = add nsw i32 %12, -1
store i32 %13, i32* %1
%14 = icmp eq i32 %12, 0
br i1 %14, label %45, label %19
15: ; preds = %39, %19
%16 = load i32, i32* %1
%17 = add nsw i32 %16, -1
store i32 %17, i32* %1
%18 = icmp eq i32 %16, 0
br i1 %18, label %45, label %19
19: ; preds = %0, %15
%20 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%21 = load i32, i32* %2
%22 = add nsw i32 %21, -1
store i32 %22, i32* %2
%23 = icmp eq i32 %21, 0
br i1 %23, label %15, label %24
24: ; preds = %19, %39
%25 = 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)
%26 = load i32, i32* %3
%27 = load i32, i32* %4
%28 = add nsw i32 %27, %26
%29 = load i32, i32* %5
%30 = add nsw i32 %28, %29
%31 = and i32 %30, 1
%32 = icmp eq i32 %31, 0
%33 = add nsw i32 %27, 1
br i1 %32, label %34, label %36
34: ; preds = %24
%35 = sdiv i32 %33, 2
br label %39
36: ; preds = %24
%37 = sdiv i32 %33, -2
%38 = add i32 %37, %27
br label %39
39: ; preds = %36, %34
%40 = phi i32 [ %38, %36 ], [ %35, %34 ]
%41 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %2
%43 = add nsw i32 %42, -1
store i32 %43, i32* %2
%44 = icmp eq i32 %42, 0
br i1 %44, label %15, label %24
45: ; preds = %15, %0
ret i32 0
}