cho.sh
Notes
Loading...

Mirror-Symmetric Tree Graph

Time limit

1s

Memory limit

128 MB

Problem

Let T be a rooted tree, and let S be an exact copy of T. For every leaf of T except the root, identify that leaf with the corresponding leaf of S. The graph obtained this way is called a mirror-symmetric tree graph.

Given an undirected connected graph, determine whether it is a mirror-symmetric tree graph.

Input

The first line contains two integers N and M, the number of vertices and the number of edges. The vertices are numbered from 1 to N.

Each of the next M lines contains two integers x and y, describing one edge. The vertices x and y are distinct, and there is at most one edge between any pair of vertices.

Output

Print YES if the given graph is a mirror-symmetric tree graph. Otherwise, print NO.

Constraints

  • 3 ≤ N, M ≤ 100,000
  • 1 ≤ x, y ≤ N
  • x ≠ y