欢迎光临散文网 会员登陆 & 注册

CF 1842A - Tenzing and Tsondu

2023-06-25 09:30 作者:您是打尖儿还是住店呢  | 我要投稿

Tsondu and Tenzing are playing a card game. Tsondu has n monsters with ability values a1,a2,…,an while Tenzing has m

 monsters with ability values b1,b2,…,bm.

Tsondu and Tenzing take turns making moves, with Tsondu going first. In each move, the current player chooses two monsters: one on their side and one on the other side. Then, these monsters will fight each other. Suppose the ability values for the chosen monsters are x and y respectively, then the ability values of the monsters will become x−y and y−x respectively. If the ability value of any monster is smaller than or equal to 0, the monster dies.

The game ends when at least one player has no monsters left alive. The winner is the player with at least one monster left alive. If both players have no monsters left alive, the game ends in a draw.


Find the result of the game when both players play optimally.


Input

Each test contains multiple test cases. The first line of input contains a single integer t (1≤t≤2⋅103) — the number of test cases. The description of test cases follows.

The first line of each test case contains two integers n and m (1≤n,m≤50) — the number of monsters Tsondu and Tenzing have respectively.

The second line of each test case contains n integers a1,a2,…,an

 (1≤ai≤109) — the ability values of Tsondu's monsters.


The third line of each test case contains m integers b1,b2,…,bm

 (1≤bi≤109) — the ability values of Tenzing's monsters.

Output

For each test case, output "Tsondu" if Tsondu wins, "Tenzing" if Tenzing wins, and "Draw" if the game ends in a draw. (Output without quotes.)


Note that the output is case-sensitive. For example, if the answer is "Tsondu", the outputs "tsondu", "TSONDU", and "tSonDu" will all be recognized as incorrect outputs.

----------------------------------------------------------------------中文

Tsondu 和 Tenzing 正在玩纸牌游戏。 Tsondu 有 n 个能力值为 a1,a2,…,an 的怪物,而 Tenzing 有 m 个

  能力值为 b1,b2,…,bm 的怪物。

梭杜和丹增轮流出手,梭杜先行。 在每次移动中,当前玩家选择两个怪物:一个在自己这边,一个在另一方。 然后,这些怪物就会互相争斗。 假设所选怪物的能力值为x

  和y分别,则怪物的能力值将分别变为x−y和y−x。 如果任何怪物的能力值小于或等于0,则该怪物死亡。

当至少一名玩家没有怪物存活时,游戏结束。 获胜者是至少有一只怪物还活着的玩家。 如果双方都没有怪物存活,则游戏以平局结束。


求双方都发挥最佳状态时的游戏结果。


输入

每个测试包含多个测试用例。 输入的第一行包含一个整数 t (1≤t≤2⋅103) — 测试用例的数量。 测试用例的描述如下。

每个测试用例的第一行包含两个整数n和m(1≤n,m≤50)——Tsondu和Tenzing分别拥有的怪物数量。

每个测试用例的第二行包含n个整数a1,a2,…,an

  (1≤ai≤109) — Tsondu的怪物的能力值。


每个测试用例的第三行包含 m 个整数 b1,b2,…,bm

  (1≤bi≤109) — 丹增怪物的能力值。

输出

对于每个测试用例,如果 Tsondu 获胜则输出“Tsondu”,如果 Tenzing 获胜则输出“Tenzing”,如果游戏以平局结束则输出“Draw”。 (输出不带引号。)


请注意,输出区分大小写。 例如,如果答案是“Tsondu”,则输出“tsondu”、“TSONDU”和“tSonDu”都将被识别为不正确的输出。

---------------------------------------------------------------------------------

依次while循环即可:


CF 1842A - Tenzing and Tsondu的评论 (共 条)

分享到微博请遵守国家法律