#C625. Minimum Initial Update Propagation

    ID: 49989 Type: Default 1000ms 256MiB

Minimum Initial Update Propagation

Minimum Initial Update Propagation

Charlie works for a computer network management company. He needs to ensure that a software update is installed on all computers. The network is represented by N computers and M bidirectional connections between them. The update can propagate from any computer that receives it directly from the main server to all computers connected in its component.

Your task is to determine the minimum number of computers that must receive the update directly from the main server so that eventually all computers receive the update. In other words, you need to count the number of connected components in the network.

Mathematically, if the network is represented as an undirected graph, you are to find the number of connected components. That is, if \(G = (V,E)\) then you should determine \(k\) such that the graph can be partitioned into \(k\) connected subgraphs.

inputFormat

The input is given via standard input (stdin) in the following format:

T
For each test case:
    N M
    u1 v1
    u2 v2
    ...
    uM vM

Here, T is the number of test cases. For each test case, the first line contains two integers N (the number of computers) and M (the number of direct connections). This is followed by M lines, each containing two integers u and v, indicating that computer u and computer v are directly connected.

outputFormat

For each test case, output a single integer on a new line, representing the minimum number of computers that need to be updated directly (i.e. the number of connected components in the network). The output should be written to standard output (stdout).

## sample
2
5 4
1 2
2 3
3 4
4 5
3 0
1

3

</p>