Under construction

Still being built. Things may change

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 NN people. Each person is numbered from 1 to NN.

The NN people sit in a circle. For each integer ii with 1≤i≤N−11 \le i \le N-1, person i+1i+1 sits to the right of person ii, and person 1 sits to the right of person NN. The game then proceeds as follows.

  1. Roll the dice to decide who starts the game and who must end it.
  2. Starting with the player who begins, each player takes a turn in order.
  3. Continue the game until a win or loss condition is met.

On a player's turn, the player follows these steps in order.

  1. Draw one tile from the wall.
  2. Choose one tile, either the drawn tile or a tile already in hand, and discard it.
  3. 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 ii can choose a tile to discard that one of the MiM_i people Li,1,…,Li,MiL_{i,1}, \dots, L_{i,M_i} may take. No one else can take person ii's discards.

The dice have already been rolled. When person II starts the game, determine whether person FF can draw the last tile of the wall and win with Haitei Raoyue.

Input

The first line contains the number of players NN and the number of tiles left in the wall PP when the game starts, separated by a space. (3≤N≤5 0003 \le N \le 5\,000, 1≤P≤1091 \le P \le 10^{9})

The second line contains the number II of the player who starts the game and the number FF of the player who must end it, separated by a space. (1≤I≤N1 \le I \le N, 1≤F≤N1 \le F \le N)

From the third line, the next NN lines describe which players can take each person's discards.

  • Line ii contains 1+Mi1+M_i integers, separated by spaces.
  • The first number MiM_i is the number of players who might take person ii's discards. (0≤Mi≤N−10 \le M_i \le N-1, ∑Mi≤5 000\sum M_i \le 5\,000)
  • The remaining numbers are Li,1,…,Li,MiL_{i,1}, \dots, L_{i,M_i}, in order. (1≤Li,j≤N1 \le L_{i,j} \le N, Li,j≠iL_{i,j} \ne i, and if j≠kj \ne k then Li,j≠Li,kL_{i,j} \ne L_{i,k})

Output

Print Tsumo if player FF can win, and Ryuukyoku if player FF 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.

Examples2

  1. Example 1

    Input
    3 2
    1 3
    1 2
    2 3 1
    0
    
    Expected output
    Tsumo
    
  2. Example 2

    Input
    5 2
    1 3
    1 4
    2 3 5
    0
    0
    0
    
    Expected output
    Ryuukyoku