#P1949C. Annual Ants' Gathering

    ID: 9076 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>dfs and similargreedytrees

Annual Ants' Gathering

No submission language available for this problem.

Description

Deep within a forest lies an ancient tree, home to nn ants living in nn tiny houses, indexed from 11 to nn, connected by the branches of the tree.

Once a year, all the ants need to gather to watch the EUC. For this, all ants move along the n1n-1 branches of the tree they live on to meet at the home of one ant.

However, this year the ants could not agree on where to meet and need your help to gather up. You can tell all the ants currently at house uu to move to house vv if there is a branch directly connecting those two houses. However, the ants ignore your command if there are fewer ants gathered in house vv than in house uu, i.e., if it would be easier for the ants from house vv to move. This even holds true if no ant at all is currently in house vv. You can give this kind of commands as many times as you want.

Is it possible for you to gather all the ants in a single house?

The first line contains one integer nn (1n2000001\leq n\leq 200\,000) — the number of ant homes.

Each of the following n1n-1 lines contains two integers uu and vv (1u,vn1\leq u, v\leq n) — there is a branch directly connecting the house uu and house vv. It is guaranteed that every ant can reach the house of any other ant just by following the branches of the tree.

Print YES\texttt{YES} if it is possible to gather all the ants in a single house. Otherwise, print NO\texttt{NO}.

Input

The first line contains one integer nn (1n2000001\leq n\leq 200\,000) — the number of ant homes.

Each of the following n1n-1 lines contains two integers uu and vv (1u,vn1\leq u, v\leq n) — there is a branch directly connecting the house uu and house vv. It is guaranteed that every ant can reach the house of any other ant just by following the branches of the tree.

Output

Print YES\texttt{YES} if it is possible to gather all the ants in a single house. Otherwise, print NO\texttt{NO}.

Sample Input 1

7
5 1
3 2
4 6
3 6
7 1
1 3

Sample Output 1

YES

Sample Input 2

5
1 4
4 2
3 2
5 3

Sample Output 2

NO

Sample Input 3

6
4 5
5 6
6 1
2 6
3 2

Sample Output 3

YES

Note

In the first sample, you can gather all the ants at house 33 as follows:

  • You tell to the ant at house 44 to move to house 66.
  • You tell to the ant at house 22 to move to house 33.
  • You tell to the two ants at house 66 to move to house 33 (which already contains two ants).
  • You tell to the ant at house 55 to move to house 11.
  • You tell to the ant at house 77 to move to house 11 (which already contains two ants).
  • You tell to the three ants at house 11 to move to house 33 (which already contains four ants).

In the second sample, it is impossible to gather all the ants in a single house.