1. 

/*
* @Lesson: ACM
* @Problem: 10608 Friends
* @Status: AC
* @Time: 1.372
* @Method: DFS, greedy
* @Author: Christoph Miesel
*/

import java.util.*;

public class Friends
{
static int N, E, from, to, greedy, counter;
static HashMap<Integer, HashSet<Integer>> map = new HashMap<Integer, HashSet<Integer>>();
static int[] visited = new int[30001];

static void clearVisited()
{
for(int i = 1; i <= N; i++)
visited[i] = 0;
}

static void dfs(int node)
{
counter++;
visited[node]++;
if(map.containsKey(node))
for(Integer i: map.get(node))
if(visited[i] == 0)
dfs(i);
}

public static void main(String... args)
{
Scanner sc = new Scanner(System.in);

int cases = sc.nextInt();
for(int c = 0; c < cases; c++)
{
map.clear();
greedy = 0;
// BEGIN Reading
N = sc.nextInt();
E = sc.nextInt();
for(int i = 1; i <= E; i++)
{
from = sc.nextInt();
to = sc.nextInt();
if(map.containsKey(from))
map.get(from).add(to);
else
{
HashSet<Integer> set = new HashSet<Integer>();
set.add(to);
map.put(from, set);
}

if(map.containsKey(to))
map.get(to).add(from);
else
{

HashSet<Integer> set = new HashSet<Integer>();
set.add(from);
map.put(to, set);
}
}
// END Reading

clearVisited();
for(int i = 1; i <= N; i++)
if(visited[i] == 0)
{
counter = 0;
dfs(i);
greedy = counter > greedy ? counter : greedy;
}
System.out.println(greedy);
}
}
}