#T453. 通信系统

通信系统

Description

A city plans to build a communication system. According to the design, this system consists of several endpoints connected by communication cables. Messages can be generated at any endpoint and can only be transmitted via cables. After receiving a message, each endpoint will forward it to all connected endpoints except the one from which the message was received. If the message originates at an endpoint, it will be sent to every connected endpoint.

To improve efficiency and conserve resources, the system must satisfy the following requirements when a message is generated at any endpoint:

  1. Every other endpoint must receive the message.
  2. No endpoint should receive the message more than once.

Given the description of the communication system, can you determine whether it meets these requirements?

Input Format

The input contains multiple test cases. Each pair of test cases is separated by a blank line.

For each test case:

  • The first line contains two integers, N and M, where N (1 ≤ N ≤ 1000) represents the number of endpoints, and M (0 ≤ M ≤ N*(N-1)/2) represents the number of communication cables.
  • The next M lines each contain two integers, A and B (1 ≤ A, B ≤ N), indicating that endpoints A and B are connected by a cable. No two endpoints are directly connected by more than one cable, and no endpoint is connected to itself.

The input ends when N and M are both 0.

Output Format

For each test case, if the given system meets the requirements, output Yes; otherwise, output No.

4 3
1 2
2 3
3 4

3 1
2 3

0 0
Yes
No

目标

CodesOnline