Symmetry: Tree
시간 제한2초메모리 제한1024 MB
트리가 주어지면 각 정점을 정수 좌표에 배치해 그린 그림이 어떤 직선에 대칭이 되도록 하거나, 불가능하면 NO를 출력한다.
문제
Given a tree with vertices, for each node , find an integer point , and then, for each edge , connect points and with a line segment, so that the following conditions hold:
- No two points coincide.
- No two line segments have common points except at both endpoints.
- There exists a line such that the shape formed by the points is symmetric about the line and the shape formed by the line segments is symmetric about the line.
입력
There are multiple test cases. The first line of input contains an integer (), the number of test cases. For each test case:
The first line contains an integer (), the number of vertices of the tree.
Each of the following lines contains two integers and (, ), denoting an edge connecting and .
Note that there are no constraints related to the sum of .
출력
For each test case:
If there is no answer, output the word "NO" on the only line.
Otherwise, output "YES" on the first line, and two integers and () in the -th of the following lines.
After that, output another line with three integers , , (, , ), denoting that the shapes are symmetric about the .
If there are multiple answers, output any one of them.