Contestants numbered through begin in a queue in that order, with contestant at the front.
The host issues commands:
P: Move the person at the front to the back.
R: Reverse the entire queue.
E: Remove the person at the front; that person goes onstage.
Determine the order in which contestants go onstage.
There are exactly occurrences of E. The queue is nonempty before every command, and the last command empties it. Passing or reversing a queue with one person leaves it unchanged.
The first line contains and : the number of contestants and commands.
The second line contains characters, each P, R, or E.
Print the contestant numbers in the order they go onstage, separated by spaces.
The commands satisfy the guarantees above.
In Sample 1, after P and R, the queue is . The next two commands remove and . Passing then puts ahead of .
In Sample 2, reversing gives . Passing gives , and then everyone leaves.
| Sample Input 1 | Sample Output 1 |
|---|---|
4 7 PREEPEE |
1 4 2 3 |
| Sample Input 2 | Sample Output 2 |
|---|---|
3 5 RPEEE |
2 1 3 |