int main() {
  int a, b;
  long long int c, d, e, f;
  char aa[201], bb[10], cc[201], dd[10], ee = "PAR", ff = "IMPAR";
  scanf("%d", &a);
  for (b = 1; b <= a; b++) {
    scanf("%s %s %s %s", aa, bb, cc, dd);
    scanf("%lld%lld", &c, &d);
    e = c + d;
    if (bb[0] == 'P') {
      if (e % 2 == 0)
        printf("%s\n", aa);
      else
        printf("%s\n", cc);
    } else {
      if (e % 2 == 0)
        printf("%s\n", cc);
      else
        printf("%s\n", aa);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f0,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xec9(%rip),%rax
mov    %al,-0x1eb(%rbp)
lea    0xeba(%rip),%rax
mov    %al,-0x1ec(%rbp)
lea    0xeb3(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1278 <main+0x158>
lea    -0x100(%rbp),%rsi
lea    -0x10a(%rbp),%rdx
lea    -0x1e0(%rbp),%rcx
lea    -0x1ea(%rbp),%r8
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xe73(%rip),%rdi
lea    -0x18(%rbp),%rsi
lea    -0x20(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x18(%rbp),%rax
add    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
movsbl -0x10a(%rbp),%eax
cmp    $0x50,%eax
jne    1219 <main+0xf9>
mov    -0x28(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    11ff <main+0xdf>
lea    -0x100(%rbp),%rsi
lea    0xe2b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1214 <main+0xf4>
lea    -0x1e0(%rbp),%rsi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1265 <main+0x145>
mov    -0x28(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
cmp    $0x0,%rdx
jne    124b <main+0x12b>
lea    -0x1e0(%rbp),%rsi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1260 <main+0x140>
lea    -0x100(%rbp),%rsi
lea    0xdc5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1265 <main+0x145>
jmp    126a <main+0x14a>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1165 <main+0x45>
xor    %eax,%eax
add    $0x1f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1d8,%rsp
lea    0xec8(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x4(%rsp)
jle    11cf <main+0xaf>
lea    0x100(%rsp),%r12
lea    0x30(%rsp),%rbx
lea    0xeac(%rip),%rbp
lea    0x10(%rsp),%r14
lea    0x8(%rsp),%r15
xor    %r13d,%r13d
lea    0xe8c(%rip),%rdi
mov    %r12,%rsi
lea    0x1c(%rsp),%rdx
mov    %rbx,%rcx
lea    0x26(%rsp),%r8
xor    %eax,%eax
call   1040 <scanf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
add    0x10(%rsp),%eax
test   $0x1,%al
mov    %rbx,%rax
cmove  %r12,%rax
mov    %r12,%rdi
cmove  %rbx,%rdi
cmpb   $0x50,0x1c(%rsp)
cmove  %rax,%rdi
call   1030 <puts@plt>
add    $0x1,%r13d
cmp    0x4(%rsp),%r13d
jl     1170 <main+0x50>
xor    %eax,%eax
add    $0x1d8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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