#K9621. Maximum Devices Alert

    ID: 39036 Type: Default 1000ms 256MiB

Maximum Devices Alert

Maximum Devices Alert

You are given a network of devices, where each device can be connected to other devices. An alert sent from a single device will propagate through all devices that are in its connected component. Given multiple test cases, your task is to determine the maximum number of devices that can receive the alert when it is initiated from the optimal device (i.e., the device that is in the largest connected component).

In each test case, you are given:

  • \( n \): the total number of devices (numbered from 1 to \( n \)).
  • \( m \): the number of connections between devices.
  • A list of \( m \) pairs \( (u, v) \) indicating that device \( u \) is connected to device \( v \) (and vice-versa).

Your goal is to find the size of the largest connected component in the graph of devices, which represents the maximum number of devices that can receive the alert from a single originating device.

Note: Recall that a connected component of a graph is a set of vertices where each vertex is reachable from any other vertex in the same set.

Mathematically, if \( G = (V, E) \) is our graph, then for each connected component \( C \subseteq V \), we want to compute \( |C| \) and output the maximum over all components.

inputFormat

The first line contains an integer \( T \) denoting the number of test cases.

For each test case, the first line contains two integers \( n \) and \( m \), the number of devices and the number of connections, respectively.

The next \( m \) lines each contain two integers \( u \) and \( v \), representing a bidirectional connection between devices \( u \) and \( v \>.

outputFormat

For each test case, output a single line containing one integer: the maximum number of devices that can receive the alert (i.e., the size of the largest connected component).

## sample
1
4 2
1 2
3 4
2

</p>