Problem Statement
There is a string $S$ of length $N$ consisting of J, O, and I. JOI-kun repeats the following operation on the string $S$ until no more operations can be performed:
- Choose $1$ place in $S$ where
J,O, andIappear contiguously in this order, and replace that part withO,I, andJin this order.
It can be proved that the repetition of operations always terminates, and that the final state of the string is uniquely determined regardless of how the operations are performed.
Given the information of the initial string $S$, write a program to find the final string $S$.
Constraints
- $3 \le N \le 500000$.
- $S$ is a string of length $N$ consisting of
J,O, andI. - $N$ is an integer.
Subtasks
- ($14$ points) $N \le 100$.
- ($27$ points) $N$ is a multiple of $3$, and $S$ is
JOIrepeated $N / 3$ times. - ($29$ points) There exists an integer $k$ ($2 \le k \le N$) such that the $1$-st through $k$-th characters of $S$ are all
J, while the $(k + 1)$-th and subsequent characters are notJ. - ($30$ points) No additional constraints.
Input
The input is given from Standard Input in the following format:
N S
Output
Print the final string $S$ in $1$ line to Standard Output.
Sample
Sample Input 1
6 JOIJOI
Sample Output 1
OIOIJJ
For example, JOI-kun may perform the operations as follows.
Initially, $S =$ JOIJOI.
- Perform the operation on the $1$-st through $3$-rd characters. Then $S =$
OIJJOI. - Perform the operation on the $4$-th through $6$-th characters. Then $S =$
OIJOIJ. - Perform the operation on the $3$-rd through $5$-th characters. Then $S =$
OIOIJJ.
Since no more operations can be performed, print OIOIJJ.
This sample input satisfies the constraints of Subtasks $1, 2, 4$.
Sample Input 2
8 JJJOIOIO
Sample Output 2
OIOIJJJO
This sample input satisfies the constraints of Subtasks $1, 3, 4$.
Sample Input 3
20 JJOIJOIJOOIJOIIJJOIO
Sample Output 3
OIOIJJJJOOIOIJIOIJJO
This sample input satisfies the constraints of Subtasks $1, 4$.