Theory of Six Handshakes#2973

Theory of Six Handshakes

1 second
64 megabytes
Medium

The theory of six degrees of separation was proposed in by American psychologists Stanley Milgram and Jeffrey Travers. Their hypothesis states that any two people on Earth are connected through a short chain of mutual acquaintances. On average, this chain consists of five intermediaries. Thus, if these two people decided to shake hands through mutual acquaintances, it would take, on average, six handshakes.

For example, if person knows person through the sequence of people , , , , , then the handshake chain is as follows: A \leftrightarrow B \leftrightarrow C \leftrightarrow D \leftrightarrow E \leftrightarrow F \leftrightarrow G. In this case, there are exactly six handshakes, and the chain of mutual acquaintances consists of exactly people (, , , , ).

In this problem, of course, we will not check the hypothesis for all inhabitants of the Earth. You are given a description of a group of people. You must determine whether, between any two members of the given group, there is a chain of mutual acquaintances that includes no more than people.

Input

The input file describes a group of people.

The first line contains two natural numbers (2 \leq N \leq 100) and (0 \leq M \leq N \cdot (N - 1) / 2) — the number of people in the group and the number of pairs of mutual acquaintances among them.

The following lines each contain two natural numbers and (1 \leq A, B \leq N) separated by a space — the indices of two members of the group who are mutual acquaintances. All members of the group are numbered from to .

Output

Output YES if, between any two members of the given group, there is a chain of mutual acquaintances that includes no more than people.

If there exist at least two people between whom no such chain exists, output NO.

Examples

Example 1

Loading
Loading