Hide

Problem C
Chaotic Cables

/problems/chaoticcables/file/statement/en/img-0001.jpg
Visualization of a possible BAPC network. CC0 by David Lohner on Flickr

Your friend Claas is in charge of designing the network for the newly constructed computer lab. Aware of the critical importance of efficiency in network design, Claas opted for the sophisticated Binary Access Point Configuration (BAPC) network topology.

A network is classified as a BAPC network precisely if we can assign a binary address of a fixed length to each device within the network, ensuring that:

  1. Devices are connected if and only if their addresses differ in exactly one bit.

  2. Each possible address is assigned to exactly one device.

Claas started out wiring devices together, but as the intricate web of connections began to take shape, doubt crept into his mind. Was the network he painstakingly constructed truly a BAPC network?

Help Claas determine if the network is a BAPC network.

Input

The input consists of:

  • One line with two integers $n$ and $m$ ($2 \le n \le 2\cdot 10^5$, $1 \le m \le 2\cdot 10^5$) the number of devices and the number of wires in the network.

  • $m$ lines with integers $a$ and $b$ ($1 \leq a, b \leq n$, $a \ne b$), indicating that there is a wire between devices $a$ and $b$.

It is guaranteed that each pair of devices is connected by at most one wire.

Output

Output “yes” if the network is a BAPC network. Otherwise, output “no”.

Sample Input 1 Sample Output 1
4 3
1 2
2 3
1 4
no
Sample Input 2 Sample Output 2
8 12
1 2
6 2
8 2
3 1
1 7
3 6
6 5
3 4
8 7
8 5
7 4
5 4
yes

Please log in to submit a solution to this problem

Log in