There is a line of people on a row. Every one has a hat, which he can be wearing (on) or not (off). Let us use those people to play a game for two players, A and B. First, decide an integer number . By turns (A begins), each player must choose some person that is currently wearing his hat, and change the state (from on to off, or the other way around) of the people to the right of , starting at . Note that the rightmost persons can never be chosen.
Fo instance, assume that ‘N’ means on, and that
‘F’ means off. If
and we pick the third person of the row below (note that his state is
on), we get the next state of the game that is shown underneath:
NFNNFFFNFFNFFF
NFFFNNFNFFNFFF
The player that cannot play loses the game. Assuming perfect play from both players, can you tell who will win?
Input consists of several cases, each one with a string
made up of only ‘N’ and ‘F’, followed by
.
Assume
.
For every case, print the name of the winner.
Input
NFFFF 5 FFFFFFFFFF 6 NFNNFFFNFFNFFF 4 NNNNNNNNN 1
Output
A B B A