#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 *, char *);
int /*<<< orphan*/ tenten(char *, int);
int main() {
  int p[2] = {0, 0};
  char game[201];
  scanf("%s", game);
  for (int i = 0; game[i]; i += 2) {
    p[game[i] - 'A'] += (int)(game[i + 1] - '0');
    if (p[0] == 10 && p[1] == 10) {
      tenten(game, i + 2);
      break;
    }
    if (p[0] > 10) {
      printf("A\n");
      break;
    }
    if (p[1] > 10) {
      printf("B\n");
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1050 <memset@plt>
lea    -0xe0(%rbp),%rsi
lea    0xe90(%rip),%rdi
call   1060 <scanf@plt>
movl   $0x0,-0xe4(%rbp)
movslq -0xe4(%rbp),%rax
cmpb   $0x0,-0xe0(%rbp,%rax,1)
je     1243 <main+0x103>
mov    -0xe4(%rbp),%eax
add    $0x1,%eax
cltq
movsbl -0xe0(%rbp,%rax,1),%ecx
ff
sub    $0x30,%ecx
movslq -0xe4(%rbp),%rax
movsbl -0xe0(%rbp,%rax,1),%eax
ff
sub    $0x41,%eax
cltq
add    -0xc(%rbp,%rax,4),%ecx
mov    %ecx,-0xc(%rbp,%rax,4)
cmpl   $0xa,-0xc(%rbp)
jne    11f4 <main+0xb4>
cmpl   $0xa,-0x8(%rbp)
jne    11f4 <main+0xb4>
lea    -0xe0(%rbp),%rdi
mov    -0xe4(%rbp),%esi
add    $0x2,%esi
call   1030 <tenten@plt>
jmp    1243 <main+0x103>
cmpl   $0xa,-0xc(%rbp)
jle    120f <main+0xcf>
lea    0xdfe(%rip),%rdi
call   1040 <printf@plt>
jmp    1243 <main+0x103>
cmpl   $0xa,-0x8(%rbp)
jle    122a <main+0xea>
lea    0xde6(%rip),%rdi
call   1040 <printf@plt>
jmp    1243 <main+0x103>
jmp    122f <main+0xef>
mov    -0xe4(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xe4(%rbp)
jmp    117f <main+0x3f>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0xe8,%rsp
movq   $0x0,0x8(%rsp)
lea    0xeb9(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x10(%rsp),%al
test   %al,%al
je     11c8 <main+0x98>
mov    $0x2,%esi
xchg   %ax,%ax
movsbl 0xf(%rsp,%rsi,1),%ecx
movsbq %al,%rax
mov    -0xfc(%rsp,%rax,4),%edx
add    %edx,%ecx
add    $0xffffffd0,%ecx
mov    %ecx,-0xfc(%rsp,%rax,4)
mov    0x8(%rsp),%ecx
mov    0xc(%rsp),%eax
cmp    $0xa,%ecx
jne    118e <main+0x5e>
cmp    $0xa,%eax
je     11a7 <main+0x77>
cmp    $0xb,%ecx
jge    11b3 <main+0x83>
cmp    $0xb,%eax
jge    11bc <main+0x8c>
movzbl 0x10(%rsp,%rsi,1),%eax
add    $0x2,%rsi
test   %al,%al
jne    1160 <main+0x30>
jmp    11c8 <main+0x98>
lea    0x10(%rsp),%rdi
call   1040 <tenten@plt>
jmp    11c8 <main+0x98>
lea    0xe4b(%rip),%rdi
jmp    11c3 <main+0x93>
lea    0xe40(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0xe8,%rsp
ret

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

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@str = [2 x i8] c"B\00"
@str.3 = [2 x i8] c"A\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to [2 x i32]*
%3 = alloca [201 x i8]
%4 = bitcast i64* %1 to i8*
store i64 0, i64* %1
%5 = getelementptr inbounds [201 x i8], [201 x i8]* %3, i64 0, i64 0
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %5)
%7 = load i8, i8* %5
%8 = icmp eq i8 %7, 0
br i1 %8, label %47, label %9
9: ; preds = %0
%10 = bitcast i64* %1 to i32*
%11 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 1
br label %12
12: ; preds = %9, %42
%13 = phi i64 [ 0, %9 ], [ %43, %42 ]
%14 = phi i8 [ %7, %9 ], [ %45, %42 ]
%15 = or i64 %13, 1
%16 = getelementptr inbounds [201 x i8], [201 x i8]* %3, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = add nsw i32 %18, -48
%20 = sext i8 %14 to i64
%21 = add nsw i64 %20, -65
%22 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = add nsw i32 %19, %23
store i32 %24, i32* %22
%25 = load i32, i32* %10
%26 = icmp eq i32 %25, 10
%27 = load i32, i32* %11
%28 = icmp eq i32 %27, 10
%29 = select i1 %26, i1 %28, i1 false
br i1 %29, label %30, label %34
30: ; preds = %12
%31 = trunc i64 %13 to i32
%32 = add nuw nsw i32 %31, 2
%33 = call i32 @tenten(i8* %5, i32 %32)
br label %47
34: ; preds = %12
%35 = icmp sgt i32 %25, 10
br i1 %35, label %36, label %38
36: ; preds = %34
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.3, i64 0, i64 0))
br label %47
38: ; preds = %34
%39 = icmp sgt i32 %27, 10
br i1 %39, label %40, label %42
40: ; preds = %38
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
br label %47
42: ; preds = %38
%43 = add nuw i64 %13, 2
%44 = getelementptr inbounds [201 x i8], [201 x i8]* %3, i64 0, i64 %43
%45 = load i8, i8* %44
%46 = icmp eq i8 %45, 0
br i1 %46, label %47, label %12
47: ; preds = %42, %0, %40, %36, %30
ret i32 0
}