#P11017. Hide And Seek
Hide And Seek
Problem Description
Drifty is playing hide-and-seek with hgcnxn.
The whole map has rooms, connected by 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 and wants to catch Drifty. Using a radar, hgcnxn knows that Drifty initially is in room . 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 , , , and the map. Determine whether within rounds, hgcnxn can possibly catch Drifty.
Input Format
This problem contains multiple test cases.
The first line contains an integer , the number of test cases.
For each test case:
The first line contains three integers , , .
The next lines each contain two nodes , , 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 be the sum of within a single test point.
For of the testdata, it is guaranteed that:
- .
Below is the detailed distribution of subtasks:
| Score | Special Property | ||
|---|---|---|---|
| A | |||
| B | |||
| None | |||
| C | |||
| 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. rooms have degree ).
- Special Property C: It is guaranteed that there is exactly one room with degree in the map, and all other rooms have degree .
Here, the degree of a room is defined as the number of corridors connected to that room.
Translated by ChatGPT 5