#K93857. Guest Connectivity

    ID: 38512 Type: Default 1000ms 256MiB

Guest Connectivity

Guest Connectivity

You are given a number of guests along with a list of bidirectional connections between them. Two guests are considered connected if they have a direct connection or if there exists a series of guests such that each adjacent pair is connected. In other words, the guests form an undirected graph and your task is to determine if the graph is connected.

Input Format: The first line of the input contains an integer \(T\), the number of test cases. Each test case starts with two integers \(N\) and \(M\) where \(N\) is the number of guests and \(M\) is the number of connections. This is followed by \(M\) lines each containing two integers \(u\) and \(v\) representing a bidirectional connection between guest \(u\) and guest \(v\).

Task: For each test case, print "Connected" if all guests are connected (directly or indirectly); otherwise, print "Not Connected".

Note: A single guest with no connections is considered connected, while a test case with more than one guest and no connections is not connected.

inputFormat

The input is read from standard input (stdin) and follows the format below:

T
N M
u1 v1
u2 v2
... (M connections)
... (next test case)

where \(T\) is the number of test cases, \(N\) is the number of guests, and \(M\) is the number of connections.

outputFormat

For each test case, output a single line containing "Connected" if all guests (nodes) are connected, and "Not Connected" otherwise. The output is written to standard output (stdout).

## sample
1
3 2
0 1
1 2
Connected