#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 *, char *);
int /*<<< orphan*/ scanf(char *, ...);
int main(void) {
  int casos;
  char nomeDoJogador01[128], opcaoDoJogador01[16], nomeDoJogador02[128],
      opcaoDoJogador02[16];
  int valorJogador01, valorJogador02;
  scanf("%d\n", &casos);
  while (casos-- > 0) {
    scanf("%s %s %s %s\n%d %d\n", nomeDoJogador01, opcaoDoJogador01,
          nomeDoJogador02, opcaoDoJogador02, &valorJogador01, &valorJogador02);
    if ((valorJogador01 + valorJogador02) % 2 != 0) {
      if (opcaoDoJogador01[0] == 'I') {
        printf("%s\n", nomeDoJogador01);
      } else {
        printf("%s\n", nomeDoJogador02);
      }
    } else {
      if (opcaoDoJogador01[0] == 'P') {
        printf("%s\n", nomeDoJogador01);
      } else {
        printf("%s\n", nomeDoJogador02);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed6(%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
jle    1236 <main+0x116>
lea    -0x90(%rbp),%rsi
lea    -0xa0(%rbp),%rdx
lea    -0x120(%rbp),%rcx
lea    -0x130(%rbp),%r8
lea    0xe85(%rip),%rdi
lea    -0x134(%rbp),%r9
lea    -0x138(%rbp),%rax
mov    %rax,(%rsp)
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x134(%rbp),%eax
add    -0x138(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     11f1 <main+0xd1>
movsbl -0xa0(%rbp),%eax
cmp    $0x49,%eax
jne    11d9 <main+0xb9>
lea    -0x90(%rbp),%rsi
lea    0xe44(%rip),%rdi
call   1030 <printf@plt>
jmp    11ec <main+0xcc>
lea    -0x120(%rbp),%rsi
lea    0xe2c(%rip),%rdi
call   1030 <printf@plt>
jmp    1231 <main+0x111>
movsbl -0xa0(%rbp),%eax
cmp    $0x50,%eax
jne    1219 <main+0xf9>
lea    -0x90(%rbp),%rsi
lea    0xe04(%rip),%rdi
call   1030 <printf@plt>
jmp    122c <main+0x10c>
lea    -0x120(%rbp),%rsi
lea    0xdec(%rip),%rdi
call   1030 <printf@plt>
jmp    1231 <main+0x111>
jmp    1144 <main+0x24>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x148,%rsp
lea    0xed7(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x14(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x14(%rsp)
test   %eax,%eax
jle    11e2 <main+0xc2>
lea    0xc0(%rsp),%rbx
lea    0x20(%rsp),%r15
lea    0x40(%rsp),%r12
lea    0x30(%rsp),%r13
lea    0x1c(%rsp),%rbp
lea    0xe99(%rip),%r14
jmp    1197 <main+0x77>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    0x14(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x14(%rsp)
test   %eax,%eax
jle    11e2 <main+0xc2>
lea    0x18(%rsp),%rax
mov    %rax,(%rsp)
lea    0xe59(%rip),%rdi
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r13,%r8
mov    %rbp,%r9
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x18(%rsp),%ecx
add    0x1c(%rsp),%ecx
mov    $0x50,%eax
test   $0x1,%cl
je     11d4 <main+0xb4>
mov    $0x49,%eax
mov    %rbx,%rsi
cmp    %al,0x20(%rsp)
je     1180 <main+0x60>
mov    %r12,%rsi
jmp    1180 <main+0x60>
xor    %eax,%eax
add    $0x148,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [19 x i8] c"%s %s %s %s\0A%d %d\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [128 x i8]
%3 = alloca [16 x i8]
%4 = alloca [128 x i8]
%5 = alloca [16 x i8]
%6 = alloca i32
%7 = alloca i32
%8 = bitcast i32* %1 to i8*
%9 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%12 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%13 = bitcast i32* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%16 = load i32, i32* %1
%17 = add nsw i32 %16, -1
store i32 %17, i32* %1
%18 = icmp sgt i32 %16, 0
br i1 %18, label %19, label %34
19: ; preds = %0, %19
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %9, i8* %10, i8* %11, i8* %12, i32* %6, i32* %7)
%21 = load i32, i32* %6
%22 = load i32, i32* %7
%23 = add nsw i32 %22, %21
%24 = and i32 %23, 1
%25 = icmp eq i32 %24, 0
%26 = load i8, i8* %10
%27 = select i1 %25, i8 80, i8 73
%28 = icmp eq i8 %26, %27
%29 = select i1 %28, i8* %9, i8* %11
%30 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %29)
%31 = load i32, i32* %1
%32 = add nsw i32 %31, -1
store i32 %32, i32* %1
%33 = icmp sgt i32 %31, 0
br i1 %33, label %19, label %34
34: ; preds = %19, %0
ret i32 0
}