#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int test;
  scanf("%d", &test);
  while (test--) {
    int g;
    scanf("%d", &g);
    int i;
    int count = 0;
    for (i = 0; i < g; i++) {
      int p;
      scanf("%d", &p);
      int piles[p];
      int j;
      for (j = 0; j < p; j++) {
        scanf("%d", &piles[j]);
        while (piles[j] > 1) {
          piles[j] -= 2;
          count++;
        }
      }
    }
    if (count % 2 != 0)
      printf("Alice\n");
    else
      printf("Bob\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%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     1271 <main+0x151>
lea    0xea6(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    123b <main+0x11b>
lea    0xe7c(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x18(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    1226 <main+0x106>
mov    -0x38(%rbp),%rsi
movslq -0x2c(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe23(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
cmpl   $0x1,(%rax,%rcx,4)
jle    1213 <main+0xf3>
mov    -0x38(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
sub    $0x2,%edx
mov    %edx,(%rax,%rcx,4)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11e2 <main+0xc2>
jmp    1218 <main+0xf8>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    11bb <main+0x9b>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1171 <main+0x51>
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     1260 <main+0x140>
lea    0xdad(%rip),%rdi
call   1030 <printf@plt>
jmp    126c <main+0x14c>
lea    0xda3(%rip),%rdi
call   1030 <printf@plt>
jmp    113f <main+0x1f>
xor    %eax,%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xec8(%rip),%rdi
lea    -0x34(%rbp),%rsi
call   1040 <scanf@plt>
subl   $0x1,-0x34(%rbp)
jae    1158 <main+0x38>
xor    %eax,%eax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xea1(%rip),%r12
jmp    1182 <main+0x62>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
subl   $0x1,-0x34(%rbp)
jb     1147 <main+0x27>
mov    %r12,%rdi
lea    -0x30(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x30(%rbp)
jle    1170 <main+0x50>
xor    %r14d,%r14d
xor    %r13d,%r13d
jmp    11b2 <main+0x92>
nopl   0x0(%rax)
mov    -0x40(%rbp),%rsp
add    $0x1,%r14d
cmp    -0x30(%rbp),%r14d
jge    1240 <main+0x120>
mov    %r12,%rdi
lea    -0x2c(%rbp),%rsi
call   1040 <scanf@plt>
mov    %rsp,%rcx
mov    -0x2c(%rbp),%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
cmpl   $0x0,-0x2c(%rbp)
mov    %rcx,-0x40(%rbp)
jle    11a0 <main+0x80>
xor    %r15d,%r15d
jmp    1201 <main+0xe1>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
movslq -0x2c(%rbp),%rax
add    $0x4,%rbx
cmp    %rax,%r15
jge    11a0 <main+0x80>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    (%rbx),%eax
cmp    $0x2,%eax
jl     11f0 <main+0xd0>
mov    $0x3,%ecx
cmovle %eax,%ecx
neg    %ecx
add    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,%edx
shr    %edx
and    $0xfffffffe,%ecx
neg    %ecx
add    %ecx,%eax
add    $0xfffffffe,%eax
add    %edx,%r13d
add    $0x1,%r13d
mov    %eax,(%rbx)
jmp    11f0 <main+0xd0>
nopl   0x0(%rax,%rax,1)
lea    0xdc0(%rip),%rdi
test   $0x1,%r13b
je     1170 <main+0x50>
jmp    1177 <main+0x57>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [7 x i8] c"Alice\0A\00"
@.str.2 = [5 x i8] c"Bob\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %11
11: ; preds = %67, %0
%12 = load i32, i32* %2
%13 = add nsw i32 %12, -1
store i32 %13, i32* %2
%14 = icmp ne i32 %12, 0
br i1 %14, label %15, label %68
15: ; preds = %11
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 0, i32* %5
store i32 0, i32* %4
br label %17
17: ; preds = %56, %15
%18 = load i32, i32* %4
%19 = load i32, i32* %3
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %59
21: ; preds = %17
%22 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %6)
%23 = load i32, i32* %6
%24 = zext i32 %23 to i64
%25 = call i8* @llvm.stacksave()
store i8* %25, i8** %7
%26 = alloca i32, i64 %24
store i64 %24, i64* %8
store i32 0, i32* %9
br label %27
27: ; preds = %51, %21
%28 = load i32, i32* %9
%29 = load i32, i32* %6
%30 = icmp slt i32 %28, %29
br i1 %30, label %31, label %54
31: ; preds = %27
%32 = load i32, i32* %9
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %26, i64 %33
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %34)
br label %36
36: ; preds = %42, %31
%37 = load i32, i32* %9
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i32, i32* %26, i64 %38
%40 = load i32, i32* %39
%41 = icmp sgt i32 %40, 1
br i1 %41, label %42, label %50
42: ; preds = %36
%43 = load i32, i32* %9
%44 = sext i32 %43 to i64
%45 = getelementptr inbounds i32, i32* %26, i64 %44
%46 = load i32, i32* %45
%47 = sub nsw i32 %46, 2
store i32 %47, i32* %45
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
store i32 %49, i32* %5
br label %36
50: ; preds = %36
br label %51
51: ; preds = %50
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
br label %27
54: ; preds = %27
%55 = load i8*, i8** %7
br label %56
56: ; preds = %54
%57 = load i32, i32* %4
%58 = add nsw i32 %57, 1
store i32 %58, i32* %4
br label %17
59: ; preds = %17
%60 = load i32, i32* %5
%61 = srem i32 %60, 2
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %65
63: ; preds = %59
%64 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %67
65: ; preds = %59
%66 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
br label %67
67: ; preds = %65, %63
br label %11
68: ; preds = %11
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@str = [4 x i8] c"Bob\00"
@str.3 = [6 x i8] c"Alice\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 %64, label %9
9: ; preds = %0
%10 = bitcast i32* %2 to i8*
%11 = bitcast i32* %3 to i8*
br label %12
12: ; preds = %9, %58
%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 %57
16: ; preds = %12, %49
%17 = phi i32 [ %51, %49 ], [ 0, %12 ]
%18 = phi i32 [ %50, %49 ], [ 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 = zext i32 %20 to i64
%22 = call i8* @llvm.stacksave()
%23 = alloca i32, i64 %21
%24 = load i32, i32* %3
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %49
26: ; preds = %16, %43
%27 = phi i64 [ %45, %43 ], [ 0, %16 ]
%28 = phi i32 [ %44, %43 ], [ %18, %16 ]
%29 = getelementptr inbounds i32, i32* %23, i64 %27
%30 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %29)
%31 = load i32, i32* %29
%32 = icmp sgt i32 %31, 1
br i1 %32, label %33, label %43
33: ; preds = %26
%34 = add nuw i32 %31, 1
%35 = call i32 @llvm.smin.i32(i32 %31, i32 3)
%36 = sub nuw i32 %34, %35
%37 = lshr i32 %36, 1
%38 = and i32 %36, -2
%39 = add i32 %28, 1
%40 = add nsw i32 %31, -2
%41 = sub nsw i32 %40, %38
%42 = add i32 %39, %37
store i32 %41, i32* %29
br label %43
43: ; preds = %33, %26
%44 = phi i32 [ %42, %33 ], [ %28, %26 ]
%45 = add nuw nsw i64 %27, 1
%46 = load i32, i32* %3
%47 = sext i32 %46 to i64
%48 = icmp slt i64 %45, %47
br i1 %48, label %26, label %49
49: ; preds = %43, %16
%50 = phi i32 [ %18, %16 ], [ %44, %43 ]
%51 = add nuw nsw i32 %17, 1
%52 = load i32, i32* %2
%53 = icmp slt i32 %51, %52
br i1 %53, label %16, label %54
54: ; preds = %49
%55 = and i32 %50, 1
%56 = icmp eq i32 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %12, %54
br label %58
58: ; preds = %54, %57
%59 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0), %57 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @str.3, i64 0, i64 0), %54 ]
%60 = call i32 @puts(i8* dereferenceable(1) %59)
%61 = load i32, i32* %1
%62 = add nsw i32 %61, -1
store i32 %62, i32* %1
%63 = icmp eq i32 %61, 0
br i1 %63, label %64, label %12
64: ; preds = %58, %0
ret i32 0
}