import java.util.*;
import java.util.regex.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;
import java.text.*;
class Main
{
public static void main (String args[]) // entry point from OS
{
Main myWork = new Main(); // create a dynamic instance
myWork.Begin(); // the true entry point
}
void Begin()
{
try
{
// Scanner sc=new Scanner(new File("in.txt"));
Scanner sc=new Scanner(System.in);
PrintWriter pr=new PrintWriter(System.out);
//default delimiter : "\\s+"
// that means spaces , tabs , newlines(form feeds , carriage returns)
// are skipped
// while(sc.hasNext())
// {
// //take input
// }
int t=0;
t=sc.nextInt();
for(int i=1;i<=t;i++)
{
int n=sc.nextInt();
//got no of matches
int canStay=0;
int deathLimit=3;
int curDeathLimit=0;
for(int j=1;j<=n;j++){
String r=sc.next();
if(curDeathLimit<deathLimit){
if(r.compareTo("W")==0){
curDeathLimit=0;
}
else if(r.compareTo("D")==0 || r.compareTo("L")==0){
curDeathLimit++;
}
canStay++;
}
}
System.out.print("Case "+i+": ");
if(curDeathLimit<deathLimit) {System.out.println("Yay! Mighty Rafa persists!");}
else{
System.out.println(canStay);}
}
pr.close();
sc.close();
}
catch(Exception e)
{
// e.printStackTrace();
System.exit(0);
}
}
}
No comments:
Post a Comment