eolymp
bolt
Try our new interface for solving problems
Problems

Friends

Friends

There is a town with $n$ citizens. It is known that some pairs of people are friends. According to the famous saying that "The friends of my friends are my friends, too" it follows that if $a$ and $b$ are friends and $b$ and $c$ are friends then $a$ and $c$ are friends, too. Your task is to count how many people there are in the largest group of friends. \InputFile Consists of several datasets. The first line consists of a line with the number of test cases to follow. The first line of each dataset contains tho numbers $n$ and $m$, where $n~(1 \le n \le 30000)$ is the number of town’s citizens and $m~(0 \le m \le 500000)$ is the number of pairs of people, which are known to be friends. Each of the following $m$ lines consists of two integers $a$ and $b~(1 \le a \le n, 1 \le b \le n, a \ne b)$ which describe that $a$ and $b$ are friends. There could be repetitions among the given pairs. \OutputFile The output for each test case should contain (on a line by itself) one number denoting how many people there are in the largest group of friends on a line by itself.
Time limit 1 second
Memory limit 128 MiB
Input example #1
2
3 2
1 2
2 3
10 12
1 2
3 1
3 4
5 4
3 5
4 6
5 2
2 1
7 10
1 2
9 10
8 9
Output example #1
3
6