#P1067B. Multihedgehog
Multihedgehog
No submission language available for this problem.
Description
Someone give a strange birthday present to Ivan. It is hedgehog — connected undirected graph in which one vertex has degree at least (we will call it center) and all other vertices has degree 1. Ivan thought that hedgehog is too boring and decided to make himself -multihedgehog.
Let us define -multihedgehog as follows:
- -multihedgehog is hedgehog: it has one vertex of degree at least and some vertices of degree 1.
- For all , -multihedgehog is -multihedgehog in which the following changes has been made for each vertex with degree 1: let be its only neighbor; remove vertex , create a new hedgehog with center at vertex and connect vertices and with an edge. New hedgehogs can differ from each other and the initial gift.
Thereby -multihedgehog is a tree. Ivan made -multihedgehog but he is not sure that he did not make any mistakes. That is why he asked you to check if his tree is indeed -multihedgehog.
First line of input contains integers , (, ) — number of vertices and hedgehog parameter.
Next lines contains two integers () — indices of vertices connected by edge.
It is guaranteed that given graph is a tree.
Print "Yes" (without quotes), if given graph is -multihedgehog, and "No" (without quotes) otherwise.
Input
First line of input contains integers , (, ) — number of vertices and hedgehog parameter.
Next lines contains two integers () — indices of vertices connected by edge.
It is guaranteed that given graph is a tree.
Output
Print "Yes" (without quotes), if given graph is -multihedgehog, and "No" (without quotes) otherwise.
Samples
Note
2-multihedgehog from the first example looks like this:
Its center is vertex . Hedgehogs created on last step are: [4 (center), 1, 2, 3], [6 (center), 7, 8, 9], [5 (center), 10, 11, 12, 13].
Tree from second example is not a hedgehog because degree of center should be at least .