-
Notifications
You must be signed in to change notification settings - Fork 0
/
P344.java
36 lines (32 loc) · 888 Bytes
/
P344.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package buclesSimples;
import java.util.Scanner;
//accepted
public class P344 {
public static void main(String[] args) {
Scanner scN = new Scanner(System.in);
int n = scN.nextInt();
for (int i = 1; i <= n; i++) {
int a = scN.nextInt();
int contM=0;
int contH=0;
for(int j=1;j<=a;j++){
String cable = scN.next();
if (cable.charAt(0)=='M'){
contM++;
} else {
contH++;
}
if (cable.charAt(1)=='H'){
contH++;
} else {
contM++;
}
}
if(contM==contH){
System.out.println("POSIBLE");
}else {
System.out.println("IMPOSIBLE");
}
}
}
}