#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 n, o = 0, t, i;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
      scanf("%d", &t);
      if (t)
        o++;
    }
    (o & 1) == 0 ? printf("%d\n", n - o) : printf("%d\n", o);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
je     11ed <main+0xcd>
movl   $0x0,-0x10(%rbp)
lea    0xe9f(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b3 <main+0x93>
lea    0xe7c(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x14(%rbp)
je     11a0 <main+0x80>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a5 <main+0x85>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1171 <main+0x51>
mov    -0x10(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
jne    11d9 <main+0xb9>
mov    -0xc(%rbp),%esi
sub    -0x10(%rbp),%esi
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
jmp    11e8 <main+0xc8>
mov    -0x10(%rbp),%esi
lea    0xe20(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0x1f>
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    0xecb(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <scanf@plt>
subl   $0x1,0x10(%rsp)
jae    1157 <main+0x37>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xea2(%rip),%r13
lea    0xc(%rsp),%r14
lea    0x14(%rsp),%r15
lea    0xe94(%rip),%r12
jmp    1197 <main+0x77>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
xor    %ebp,%ebp
sub    %ebp,%eax
mov    %eax,%ebp
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
subl   $0x1,0x10(%rsp)
jb     1146 <main+0x26>
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1180 <main+0x60>
xor    %ebx,%ebx
xor    %ebp,%ebp
xchg   %ax,%ax
mov    %r13,%rdi
mov    %r15,%rsi
call   1040 <scanf@plt>
cmpl   $0x1,0x14(%rsp)
sbb    $0xffffffff,%ebp
add    $0x1,%ebx
mov    0xc(%rsp),%eax
cmp    %eax,%ebx
jl     11b0 <main+0x90>
test   $0x1,%bpl
je     1182 <main+0x62>
jmp    1186 <main+0x66>

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

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