Tree Escape

On a rooted tree where each leaf starts with one piece, players alternately move a piece to its parent and remove it at the root; decide if the first player wins.

Hard9Game theoryTreeDFSDynamic programmingNo attempts yetTime limit2sMemory limit512 MB

Problem

Seongwon moves first and Hyeongseok moves second in a board game played on a tree. The board is a tree with NN vertices numbered from 11 to NN. Vertex 11 is the root node, and the parent child relation is defined with respect to the root. A node without children is called a leaf node.

The two players alternate moving one piece, with Seongwon to move first. At the start, every leaf node holds exactly one piece. On your turn, choose one piece on the board and move it to the parent of the node it stands on. Several pieces may share one node. If the moved piece reaches the root node, remove it from the board at once. After moving, pass the turn to the opponent. A player who cannot choose a piece because the board holds no pieces loses.

Write a program that looks only at the shape of the board and decides whether Seongwon can win with optimal play.

Input

The first line gives the number of vertices NN (2N500,0002 \le N \le 500{,}000).

Each of the following N1N-1 lines describes an edge. Each line gives two natural numbers aa and bb (1a,bN1 \le a, b \le N, aba \ne b), meaning vertices aa and bb are joined by an edge.

Output

Print Yes if Seongwon can win with optimal play, and print No otherwise.