#K53122. Fully Connected Communication Network

    ID: 29462 Type: Default 1000ms 256MiB

Fully Connected Communication Network

Fully Connected Communication Network

In this problem, you are given a communication network consisting of drum towers. Each tower is linked with other towers by bidirectional connections. Two towers are considered connected if there is a direct connection or a series of connections between them. The network is said to be fully connected if every tower is reachable from any other tower.

Mathematically, a network with (N) towers is fully connected if and only if there exists a path between any two towers. Your task is to determine whether the network is fully connected or not.

For example, given 4 towers and connections (1, 2) and (3, 4), the network is not fully connected because towers 3 and 4 are isolated from towers 1 and 2. However, if the connections are (1, 2), (2, 3), and (3, 4), then the network is fully connected.

Read the input from stdin and output your results to stdout.

inputFormat

The input begins with an integer T, representing the number of test cases. Each test case follows:

  • The first line contains two integers N and M, where N is the number of drum towers and M is the number of connections.
  • The next M lines each contain two integers A and B, representing a bidirectional connection between tower A and tower B.

Towers are numbered from 1 to N.

outputFormat

For each test case, output a single line containing Yes if the network is fully connected, and No otherwise. The output for each test case should be printed on a new line.## sample

3
4 2
1 2
3 4
4 4
1 2
2 3
3 4
4 1
1 0
No

Yes Yes

</p>