QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 512 MB Points totaux : 100

#9993. Imyourfan

Statistiques

Teacher W is playing a game with his fan, Menji.

There are $n$ cards on the table, numbered $1$ to $n$. Each card has a letter $s_i$ written on it, where $s_i \in \{\texttt{X}, \texttt{W}, \texttt{M}\}$. It is guaranteed that there is at least one $\texttt{W}$ and at least one $\texttt{M}$.

Teacher W and Menji take turns, with Teacher W going first. On a player's turn, they choose an interval $[l, r]$ ($1 \leq l \leq r \leq n$) such that the interval contains no cards with the letter $\texttt{X}$, and remove all cards within that interval.

If, after any move, all $\texttt{W}$ and $\texttt{M}$ cards have been removed, the game ends in a draw. Otherwise, if after a move all $\texttt{W}$ cards have been removed, Teacher W wins. If after a move all $\texttt{M}$ cards have been removed, Menji wins.

Teacher W and Menji are both perfectly rational. Given the string $s_1 \dots s_n$, determine the outcome of the game. Output Water if Teacher W wins, Menji if Menji wins, and Draw if the game ends in a draw.

Input

The input is read from standard input.

This problem contains multiple test cases.

The first line contains an integer $T$ ($1 \leq T \leq 10^5$), representing the number of test cases.

For each test case:

A single string $s$ ($2 \leq |s| \leq 10^5$) is given, where $s_i$ is the letter on card $i$.

Output

Output to standard output.

For each test case, output a single string: Water if Teacher W wins, Menji if Menji wins, and Draw if the game ends in a draw.

Examples

Input 1

6
WMW
MWM
WMWXMWM
WWWXMMMXWWW
MMMXWWWXMMM
WMWMWMWWMWW

Output 1

Draw
Water
Draw
Menji
Water
Draw

Note 1

  • For the first test case, if Teacher W removes all cards at once, the game is a draw. Otherwise, Teacher W cannot remove both $\texttt{W}$ cards at the same time, and Menji can then remove the $\texttt{M}$ card and win. Therefore, Teacher W will choose to remove all cards, resulting in a draw.

  • For the second test case, Teacher W can remove the $\texttt{W}$ card directly and win.

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.