Moon Caught from the Sea
Time limit3sMemory limit1024 MB
- Level
Not classified yet
- Solved
- No attempts yet
Problem
Did you know that mahjong is a cooperative game?
Sea Bottom Mahjong is a cooperative game played by people. Each person is numbered from 1 to .
The people sit in a circle. For each integer with , person sits to the right of person , and person 1 sits to the right of person . The game then proceeds as follows.
- Roll the dice to decide who starts the game and who must end it.
- Starting with the player who begins, each player takes a turn in order.
- Continue the game until a win or loss condition is met.
On a player's turn, the player follows these steps in order.
- Draw one tile from the wall.
- Choose one tile, either the drawn tile or a tile already in hand, and discard it.
- Pass the turn to the player on the right.
The wall is the stack of mahjong tiles. The last tile of the wall is special. If the player who must end the game draws this tile, that player wins with Haitei Raoyue (海底撈月). If any other player draws it, that player loses.
In addition, depending on the conditions, a player may take a tile that another player has just discarded. This can happen between steps 2 and 3 of that player's turn. The following situations and restrictions apply.
- The player takes the discarded tile. The player ignores the normal turn order and immediately takes a turn.
- Because the tile comes from the discard pile instead of the wall, step 1 of drawing from the wall is skipped.
- The number of tiles left in the wall does not change.
- Two or more people cannot take the same discard. If several people want it, they decide by agreement.
- A player cannot take their own discard.
Not everyone can take everyone else's discards. Person can choose a tile to discard that one of the people may take. No one else can take person 's discards.
The dice have already been rolled. When person starts the game, determine whether person can draw the last tile of the wall and win with Haitei Raoyue.
Input
The first line contains the number of players and the number of tiles left in the wall when the game starts, separated by a space. (, )
The second line contains the number of the player who starts the game and the number of the player who must end it, separated by a space. (, )
From the third line, the next lines describe which players can take each person's discards.
- Line contains integers, separated by spaces.
- The first number is the number of players who might take person 's discards. (, )
- The remaining numbers are , in order. (, , and if then )
Output
Print Tsumo if player can win, and Ryuukyoku if player cannot win.
Hint
The game in this statement is a variant of mahjong and may differ from real mahjong.
Haitei Raoyue (海底撈月) or Kaitei Mogetsu (海底摸月) means fishing the moon out of the deep sea. It is a yaku in mahjong.