import java.util.Scanner;
public class Q11586 {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int loop = Integer.parseInt(cin.nextLine());
boolean flag;
for(int i=0; i< loop ; i++){
flag =true;
int FF=0, FM=0, RF=0, RM=0;
String str = cin.nextLine();
if(str.isEmpty()){
System.out.println("LOOP");
continue;
}
String[] tokens = str.split(" ");
if(tokens.length>1){
for(int j = 0; j< tokens.length; j++){
if(tokens[j].charAt(0)=='M'){
FM++;
}
else if(tokens[j].charAt(0)=='F'){
FF++;
}
if(tokens[j].charAt(1)=='F'){
RF++;
}
else if(tokens[j].charAt(1)=='M'){
RM++;
}
}
}else{
System.out.println("NO LOOP");
continue;
}
if((FM==RF) && (FF==RM)){
System.out.println("LOOP");
}else{
System.out.println("NO LOOP");
}
}
}
}
2009年6月24日 星期三
ACM Q11586
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言