This summer, Antun and Branka stumbled upon a very interesting beach, which was
completely covered with plastic 'pebbles' brought by the sea from the containers that
fell from the cargo ships. They decided to take back with them
Their game proceeds as follows: in the beginning, they place the
Constraints
Subtask | Points | Constraints |
---|---|---|
1 | 10 | |
2 | 20 | |
3 | 40 |
Input Specification
The first line contains two integers,
The second line contains a sequence of C
or P
, where C
denotes a red pebble, and P
denotes a
blue pebble. The character C
appears at least
Output Specification
If Antun can win regardless of Branka's moves, you should print DA
; otherwise, print NE
.
Sample Input 1
4 1
CCCP
Sample Output 1
DA
Sample Input 2
8 2
PCPPCCCC
Sample Output 2
DA
Explanation for Sample Output 2
Antun can take a blue pebble from the left (CPPCCCC
). Then, Branka has to take a red pebble.
If she takes a pebble from the left (PPCCCC
), Antun will take the first, and Branka the second blue pebble
on the left, after which only red pebbles remain and Branka will lose.
If she takes a pebble from the right (CPPCCC
), Antun can take another pebble from the right and then
Branka will again have to take another red pebble and lose.
Sample Input 3
9 1
PPCPPCPPC
Sample Output 3
NE
Comments