QOJ.ac

QOJ

実行時間制限: 1.0 s メモリ制限: 1024 MB 満点: 100 ハック可能 ✓

#15230. Chessboard

統計

Alice and Bob... No! The game is invented by Mandy and brz. They are going to play a game on a $2 \times n$ grid.

As described above, they have a $2 \times n$ grid, where each cell has a score. The score of the cell in row $i$ and column $j$ is $a_{i,j}$. Mandy's piece starts at the top-left corner (row 1, column 1), and brz's piece starts at the bottom-right corner (row 2, column $n$). First, they each collect the score of the cell their piece is currently on, and then the scores of these two positions disappear.

Then, the two players take turns, with Mandy going first. In each turn, a player can move their piece to an adjacent cell (up, down, left, or right) or choose not to move. A move cannot go outside the grid, and a piece cannot move to a cell that has no score. After moving, the player collects the score of that cell, and then the score of that cell disappears.

If both sides cannot make a move, the game ends. The player with the higher total score wins. If both players are perfect, and both want to win as much as possible (if they cannot win, they try to draw), please calculate in advance who will be the final winner.

Input

The first line contains an integer $T$ ($1 \le T \le 10^5$), representing the number of games Mandy and brz play.

For each game, the first line contains an integer $n$ ($1 \le n \le 2 \times 10^5$).

The next two lines each contain $n$ integers, representing $a_{i,j}$ ($1 \le a_{i,j} \le 10^9$).

It is guaranteed that for all games, $\sum n \le 2 \times 10^5$.

Output

Output $T$ lines, each representing the result of a game.

If Mandy wins, output "Mandy" (without quotes); if brz wins, output "brz" (without quotes); otherwise, output "draw" (without quotes) to indicate a draw.

Examples

Input 1

3
1
3
2
3
1 2 3
3 2 1
10
3 2 1 3 3 2 3 9 4 2
1 3 1 1 4 3 9 3 4 1

Output 1

Mandy
draw
brz

Note

For the first example, Mandy starts by collecting 3, brz starts by collecting 2, and then neither can move, so the game ends, and Mandy wins.

For the second example, both start by collecting 1. If Mandy chooses to move down to collect 3, then brz can choose to move left to collect 2. After that, Mandy cannot move because the scores of the surrounding cells have already been collected, so brz can collect the remaining scores and win. However, if Mandy chooses to move right to collect 2, then brz can choose to move left to collect 1. Mandy cannot move, so brz will collect the remaining scores and win. Since brz can collect 3, and Mandy can collect 3, the game ends in a draw.

For the third example, please analyze it yourself.

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.