Complete Mirror
시간 제한1초메모리 제한1024 MB
트리에서 같은 거리에 있는 모든 정점의 차수가 같아지는 루트 정점을 찾고, 없으면 -1을 출력한다.
문제
You have given tree consist of vertices. Select a vertex as root vertex that satisfies the condition below.
- For all vertices and , if (, ) (, then () (), where means the number of vertices connected to that vertex, and means the number of edges between two vertices.
Determine and find if there is such root vertex in the tree. If there are multiple answers, find any of them.
입력
The first line contains a single integer () --- the number of vertices.
Each of the next lines contains two integers and () --- it means there is an edge exist between and . It is guaranteed that the graph forms tree.
출력
If there is such root vertex exists, print any of them. Otherwise, print .
힌트
This is the picture for the first example. , , also can be a valid answer. 
This is the picture for the second example. You can see that it's impossible to find such root vertex.
