#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 */
scalar_t__ EOF;
int /*<<< orphan*/ printf(char *, int, ...);
scalar_t__ scanf(char *, ...);
int main() {
  int testCase;
  while (scanf("%d", &testCase) != EOF) {
    int counter;
    for (counter = 1; counter <= testCase; counter++) {
      int y;
      scanf("%d", &y);
      int i, sec = 1, job_lost = 0;
      for (i = 0; i < y; i++) {
        if (sec == 3) {
          job_lost = 1;
          break;
        }
        char in_result;
        scanf("%c", &in_result);
        if (in_result == 'W') {
          sec = 1;
        } else {
          sec++;
        }
      }
      if (job_lost == 0)
        printf("Case %d: Yay! Mighty Rafa persists!\n", counter);
      else
        printf("Case %d: %d\n", counter, i + 1);
    }
  }
  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
mov    $0x0,%al
call   1040 <scanf@plt>
mov    0x2ea0(%rip),%rcx
cmp    (%rcx),%rax
je     1243 <main+0x123>
movl   $0x1,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     123e <main+0x11e>
lea    0xe95(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11f4 <main+0xd4>
cmpl   $0x3,-0x18(%rbp)
jne    11ad <main+0x8d>
movl   $0x1,-0x1c(%rbp)
jmp    11f4 <main+0xd4>
lea    0xe4f(%rip),%rdi
lea    -0x1d(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x1d(%rbp),%eax
cmp    $0x57,%eax
jne    11d8 <main+0xb8>
movl   $0x1,-0x18(%rbp)
jmp    11e1 <main+0xc1>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e6 <main+0xc6>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    118b <main+0x6b>
cmpl   $0x0,-0x1c(%rbp)
jne    1214 <main+0xf4>
mov    -0xc(%rbp),%esi
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    122b <main+0x10b>
mov    -0xc(%rbp),%esi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
lea    0xe07(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1230 <main+0x110>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1158 <main+0x38>
jmp    112f <main+0xf>
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
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x2ea0(%rip),%rcx
cmp    (%rcx),%rax
jne    115e <main+0x3e>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe9e(%rip),%rbx
lea    0xf(%rsp),%rbp
mov    $0x1,%r15d
jmp    119f <main+0x7f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
lea    0xe79(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x2e4e(%rip),%rcx
cmp    (%rcx),%rax
je     114d <main+0x2d>
cmpl   $0x0,0x10(%rsp)
jle    1180 <main+0x60>
mov    $0x1,%r12d
jmp    11d0 <main+0xb0>
xchg   %ax,%ax
lea    0xe4f(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x1(%r12),%eax
cmp    0x10(%rsp),%r12d
mov    %eax,%r12d
jge    1180 <main+0x60>
lea    0xe29(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x14(%rsp)
jle    11b0 <main+0x90>
mov    $0x1,%r14d
mov    $0x1,%r13d
cs nopw 0x0(%rax,%rax,1)
cmp    $0x3,%r13d
je     1230 <main+0x110>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
add    $0x1,%r13d
cmpb   $0x57,0xf(%rsp)
cmove  %r15d,%r13d
lea    0x1(%r14),%eax
cmp    0x14(%rsp),%r14d
mov    %eax,%r14d
jl     1200 <main+0xe0>
jmp    11b0 <main+0x90>
lea    0xdf4(%rip),%rdi
mov    %r12d,%esi
mov    %r14d,%edx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11c1 <main+0xa1>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [37 x i8] c"Case %d: Yay! Mighty Rafa persists!\0A\00"
@.str.3 = [13 x i8] c"Case %d: %d\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 i32
%8 = alloca i8
store i32 0, i32* %1
br label %9
9: ; preds = %56, %0
%10 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%11 = load i64, i64* @EOF
%12 = icmp ne i64 %10, %11
br i1 %12, label %13, label %57
13: ; preds = %9
store i32 1, i32* %3
br label %14
14: ; preds = %53, %13
%15 = load i32, i32* %3
%16 = load i32, i32* %2
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %56
18: ; preds = %14
%19 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %4)
store i32 1, i32* %6
store i32 0, i32* %7
store i32 0, i32* %5
br label %20
20: ; preds = %38, %18
%21 = load i32, i32* %5
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %41
24: ; preds = %20
%25 = load i32, i32* %6
%26 = icmp eq i32 %25, 3
br i1 %26, label %27, label %28
27: ; preds = %24
store i32 1, i32* %7
br label %41
28: ; preds = %24
%29 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%30 = load i8, i8* %8
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 87
br i1 %32, label %33, label %34
33: ; preds = %28
store i32 1, i32* %6
br label %37
34: ; preds = %28
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %37
37: ; preds = %34, %33
br label %38
38: ; preds = %37
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 1
store i32 %40, i32* %5
br label %20
41: ; preds = %27, %20
%42 = load i32, i32* %7
%43 = icmp eq i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %41
%45 = load i32, i32* %3
%46 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %45)
br label %52
47: ; preds = %41
%48 = load i32, i32* %3
%49 = load i32, i32* %5
%50 = add nsw i32 %49, 1
%51 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %48, i32 %50)
br label %52
52: ; preds = %47, %44
br label %53
53: ; preds = %52
%54 = load i32, i32* %3
%55 = add nsw i32 %54, 1
store i32 %55, i32* %3
br label %14
56: ; preds = %14
br label %9
57: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@EOF = global i64 0
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [37 x i8] c"Case %d: Yay! Mighty Rafa persists!\0A\00"
@.str.3 = [13 x i8] c"Case %d: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = bitcast i32* %1 to i8*
%5 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%6 = load i64, i64* @EOF
%7 = icmp eq i64 %5, %6
br i1 %7, label %44, label %8
8: ; preds = %0
%9 = bitcast i32* %2 to i8*
br label %14
10: ; preds = %40, %14
%11 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%12 = load i64, i64* @EOF
%13 = icmp eq i64 %11, %12
br i1 %13, label %44, label %14
14: ; preds = %8, %10
%15 = load i32, i32* %1
%16 = icmp slt i32 %15, 1
br i1 %16, label %10, label %17
17: ; preds = %14, %40
%18 = phi i32 [ %41, %40 ], [ 1, %14 ]
%19 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%20 = load i32, i32* %2
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %35
22: ; preds = %17, %26
%23 = phi i32 [ %31, %26 ], [ 1, %17 ]
%24 = phi i32 [ %32, %26 ], [ 0, %17 ]
%25 = icmp eq i32 %23, 3
br i1 %25, label %37, label %26
26: ; preds = %22
%27 = call i64 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%28 = load i8, i8* %3
%29 = icmp eq i8 %28, 87
%30 = add nsw i32 %23, 1
%31 = select i1 %29, i32 1, i32 %30
%32 = add nuw nsw i32 %24, 1
%33 = load i32, i32* %2
%34 = icmp slt i32 %32, %33
br i1 %34, label %22, label %35
35: ; preds = %26, %17
%36 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %40
37: ; preds = %22
%38 = add nuw nsw i32 %24, 1
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %18, i32 %38)
br label %40
40: ; preds = %37, %35
%41 = add nuw nsw i32 %18, 1
%42 = load i32, i32* %1
%43 = icmp slt i32 %18, %42
br i1 %43, label %17, label %10
44: ; preds = %10, %0
ret i32 0
}