#P11017. Hide And Seek

Hide And Seek

Problem Description

Drifty is playing hide-and-seek with hgcnxn.

The whole map has nn rooms, connected by n1n-1 corridors (it is guaranteed that any two rooms are reachable from each other).

In each round of the game, hgcnxn moves first, and Drifty moves after (in particular, hgcnxn must move exactly one step, while Drifty may choose to stay still).

hgcnxn starts from room pp and wants to catch Drifty. Using a radar, hgcnxn knows that Drifty initially is in room qq. hgcnxn will design an as-optimal-as-possible capture plan in advance, and then follow this plan to chase Drifty. However, hgcnxn does not know Drifty's position in the later rounds.

But Drifty is even more cunning: he knows hgcnxn's entire plan in advance, and uses the best strategy to try to avoid hgcnxn. Still, due to the map, Drifty may end up being caught.

In particular, hgcnxn does not know that Drifty can know his entire plan in advance.

Now you are given nn, pp, qq, and the map. Determine whether within 1010010^{100} rounds, hgcnxn can possibly catch Drifty.

Input Format

This problem contains multiple test cases.

The first line contains an integer TT, the number of test cases.

For each test case:

The first line contains three integers nn, pp, qq.

The next n1n-1 lines each contain two nodes uu, vv, indicating a corridor connecting the two rooms.

Output Format

For each test case:

Output one string. If hgcnxn can possibly catch Drifty, output hgcnxn; otherwise output Drifty.

In particular, for judging, letter case does not matter.

If the correct output is Drifty but you output driFtY, you will still be judged as correct.

2
3 1 3
1 2
2 3
5 2 4
1 2
1 3
1 4
1 5
hgcnxn
hgcnxn

Hint

Constraints

Let n\sum n be the sum of nn within a single test point.

For 100%100\% of the testdata, it is guaranteed that:

  • 3n2×1053\le \sum n\le 2\times 10^5
  • 1p,qn1\le p,q\le n
  • 1T1031\le T\le 10^3.

Below is the detailed distribution of subtasks:

Subtask\text{Subtask} n\sum n\leq Score Special Property
00 2×1052\times 10^5 11 A
11 22 B
22 77 33 None
33 2×1052\times 10^5 99 C
44 8585 None
  • Special Property A: It is guaranteed that all given maps are paths.
  • Special Property B: It is guaranteed that all given maps are star graphs (i.e. n1n-1 rooms have degree 11).
  • Special Property C: It is guaranteed that there is exactly one room with degree 33 in the map, and all other rooms have degree 2\le 2.

Here, the degree of a room is defined as the number of corridors connected to that room.

Translated by ChatGPT 5