Bunkers
InterviewTime limit2sMemory limit1024 MB
Given a tree of n nodes, decide whether one vertex has degree 2 and its two branches are equal-sized mirror images.
Problem
Petya and Vasya play spies with great enthusiasm. Today they plan where their secret bunkers and headquarters will be.
They decided they need exactly bunkers, numbered from to for secrecy. Some of them will be connected by two-way tunnels, and for reliability and secrecy, any bunker can be reached from any other bunker in exactly one way. The boys have already decided which bunkers are connected, but they cannot choose which bunker becomes the headquarters. They want to pick it and split the remaining bunkers between themselves so that each gets the same number of bunkers, and exactly two tunnels lead to the headquarters: one from a bunker belonging to Vasya, and one from a bunker belonging to Petya.
The tired Petya went home, and in the morning Vasya showed him a plan where bunkers were drawn as points and tunnels as segments. Vasya also chose the headquarters so that the plan is symmetric about a line passing through the point that stands for the headquarters.
Petya quickly pointed out that Vasya had drawn only half of the bunkers. He then wondered whether it is possible to choose a headquarters and draw such a symmetric plan.
Input
The first line contains one integer (), the number of bunkers. Each of the next lines contains two integers and (), the numbers of the bunkers joined by the -th tunnel. It is guaranteed that there is exactly one path between any two bunkers.
Output
Print YES if it is possible to choose the headquarters and draw such a plan, or NO if it is impossible.