QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 512 MB 總分: 100

#16548. Game

统计

Xiao C and Xiao D are playing a thriving game.

This game features 3 types of cards: Kill, Dodge, and Slash. Their uses are as follows:

  • Kill: Used against the opponent. The opponent must use a Dodge card, otherwise they lose the game; or respond to the opponent's Slash.
  • Dodge: Used to respond to the opponent's Kill.
  • Slash: Used against the opponent. The opponent must use a Kill card, otherwise they lose the game.

Players must discard any card they use.

Starting with Xiao C, turns alternate between Xiao C and Xiao D. During a player's turn, they may play any number of Kill and Slash cards, and the opponent must provide the corresponding response. Of course, a player may also choose not to play any cards and pass the turn to the opponent.

Xiao C has $c_1$ Kills, $c_2$ Dodges, and $c_3$ Slashes. Xiao D has $d_1$ Kills, $d_2$ Dodges, and $d_3$ Slashes. Both players know each other's hand. Determine the outcome of the game assuming both players play optimally.

Input

This problem contains multiple test cases.

The first line contains an integer $T$, representing the number of test cases.

Each test case consists of a single line containing six integers $c_1, c_2, c_3, d_1, d_2, d_3$.

Output

For each test case, output one line:

  • If Xiao C can win assuming optimal play from both sides, output C.
  • If Xiao D can win assuming optimal play from both sides, output D.
  • If the game results in a draw (neither can win) assuming optimal play from both sides, output E.

Examples

Input 1

3
3 1 4 1 5 9
1 1 4 5 1 4
5 2 1 2 6 3

Output 1

C
D
E

Note 1

For the first test case, Xiao C can play a Slash, and after Xiao D responds with a Kill, play another Slash. At this point, Xiao D has run out of Kills and cannot respond, thus losing the game.

Example 2

See game/game2.in and game/game2.ans in the additional files.

Constraints

For $100\%$ of the data, $1 \le T \le 10^5$, $0 \le c_1, c_2, c_3, d_1, d_2, d_3 \le 10^9$.

Test Case ID Special Properties
$1\sim3$ $c_3=d_3=0$
$4\sim6$ $c_1=d_2$ and $c_2=d_1$
$7\sim10$ None

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.