Catalan Game
Time limit1sMemory limit1024 MB
- Level
Not classified yet
- Solved
- No attempts yet
Problem
A parenthesis string is a string made only of open parentheses ( and close parentheses ). A correct parenthesis string is defined by the following rules.
- The empty string is a correct parenthesis string.
- If is a correct parenthesis string, then is also a correct parenthesis string.
- If and are correct parenthesis strings, then , the concatenation of the two, is also a correct parenthesis string.
Any parenthesis string that cannot be built by this process is not a correct parenthesis string.
Junhui recently learned that the number of correct parenthesis strings of length is the Catalan number . Junhui loves correct parenthesis strings, and is upset that they appear too rarely among all parenthesis strings.
Jimin wants to comfort Junhui by showing that there are plenty of correct parenthesis strings. To do so, Jimin wants to win the following game against Junhui.
You are given an incorrect parenthesis string of length . The two players take turns removing either the first character or the last character of . They continue until there are no characters left to remove. If at some point during the game becomes a non-empty correct parenthesis string, Jimin wins. If no such moment occurs before the game ends, Junhui wins.
Jimin moves first. Given and , determine who wins if both players always play optimally.
Input
The first line contains the length of the parenthesis string.
The second line contains the parenthesis string .
Output
Print the name of the winner when both players play optimally.
Print jimin if Jimin wins, and junhui if Junhui wins.
Constraints
- Every character of is
(or). - is not a correct parenthesis string.