| TheForces Round #43 (DIV2-Forces) |
|---|
| Finished |
You are given a tree with $$$n$$$ nodes.
Your task is to delete the entire tree with the following operation:
If it is possible to delete the entire tree with operations, output any scheme. Otherwise, output $$$-1$$$ instead.
The input consists of multiple test cases. The first line of the input contains an integer $$$t$$$ ($$$1 \leq t \leq 5 \cdot 10^4$$$), the number of test cases.
The first line contains an integer $$$n$$$ $$$(2 \leq n \leq 2000)$$$ — the number of vertices in the tree.
The next $$$n-1$$$ lines each contain two integers $$$u$$$ and $$$v$$$ ($$$1 \leq u, v \leq n$$$, $$$u \neq v$$$), indicating an edge between nodes $$$u$$$ and $$$v$$$.
It is guaranteed that the given input forms a tree.
It is guaranteed that the sum of $$$n^2$$$ over all test cases does not exceed $$$4 \cdot 10^6$$$.
If it is possible to delete the entire tree with operations:
Otherwise, output $$$-1$$$ instead.
431 22 341 22 32 451 21 32 42 571 21 31 44 55 65 7
1 3 1 -1 2 4 5 1 3 -1
In the second test case, no matter which $$$2$$$ nodes you choose at first, there will always be at least $$$1$$$ node that will be disconnected from the tree and can not be deleted any more.
In the third test case, select nodes $$$4$$$ and $$$5$$$ and delete every node in the simple path from $$$4$$$ to $$$5$$$, along with the edges connected to those nodes. Repeat the same process for nodes $$$1$$$ and $$$3$$$ (The nodes and edges to be deleted are marked in red).
| Name |
|---|


