QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 1024 MB Total points: 100

#23903. Next Character

Statistics

You are given a string $S$ of length $N$. Each character of $S$ is one of J, O, or I.

Bitaro the Beaver performed $N - 1$ actions. The $i$-th action ($1 \le i \le N - 1$) was performed as follows:

  • Check the $(i + 1)$-th character of $S$. Furthermore, if the $(i + 1)$-th character of $S$ was J, write the $i$-th character of $S$ on the blackboard.

Output all the characters written by Bitaro on the blackboard during the $N - 1$ actions, in the order Bitaro wrote them, separated by newlines.

Input

The input is given from standard input in the following format:

N
S

Output

Output all the characters written by Bitaro on the blackboard during the $N - 1$ actions, in the order Bitaro wrote them, separated by newlines.

Constraints

  • $2 \le N \le 100$.
  • $S$ is a string of length $N$.
  • Each character of $S$ is one of J, O, or I.
  • $N$ is an integer.
  • There is at least $1$ character written on the blackboard.

Examples

Input 1

6
IOJOIJ

Output 1

O
I

Bitaro performed $5$ actions as follows:

  • In the $1$-st action, he checked the $2$-nd character of $S$.
  • In the $2$-nd action, he checked the $3$-rd character of $S$. Furthermore, since the $3$-rd character of $S$ was J, he wrote the $2$-nd character of $S$, which is O, on the blackboard.
  • In the $3$-rd action, he checked the $4$-th character of $S$.
  • In the $4$-th action, he checked the $5$-th character of $S$.
  • In the $5$-th action, he checked the $6$-th character of $S$. Furthermore, since the $6$-th character of $S$ was J, he wrote the $5$-th character of $S$, which is I, on the blackboard.

Therefore, output O and I written by Bitaro on the blackboard in this order, separated by a newline.

Input 2

4
JJOI

Output 2

J

In the $1$-st action, Bitaro wrote the $1$-st character of $S$, which is J, on the blackboard. In the $2$-nd and $3$-rd actions, he wrote nothing on the blackboard.

Therefore, output J written by Bitaro on the blackboard.

Input 3

7
IOJOJOJ

Output 3

O
O
O

Input 4

5
JJJJJ

Output 4

J
J
J
J

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.