// Arup Guha
// 3/20/2021
// Solution to 2021 UCF HS Contest Problem: Blob Tag

import java.util.*;

public class blob {

	public static int n;
	public static ArrayList<Integer>[] g;
	
	public static void main(String[] args) {
		
		// Get # of cases.
		Scanner stdin = new Scanner(System.in);
		int nC = stdin.nextInt();
		
		// Process cases.
		for (int loop=0; loop<nC; loop++) {
		
			// Set up the graph.
			n = stdin.nextInt();
			int numE = stdin.nextInt();
			g = new ArrayList[n];
			for (int i=0; i<n; i++) g[i] = new ArrayList<Integer>();
		
			// Read in the edges.
			for (int i=0; i<numE; i++) {
			
				// Get the two kids.
				int u = stdin.nextInt()-1;
				int v = stdin.nextInt()-1;
				
				// We only add an edge if both degrees are < 2.
				if (g[u].size() < 2 && g[v].size() < 2) {
					g[u].add(v);
					g[v].add(u);
				}
			}
			
			// Marks who we've visited in the graph.
			boolean[] used = new boolean[n];
			int res = 1;
			
			// Find the size of the largest component of this graph.
			for (int i=0; i<n; i++) {
				if (!used[i]) 
					res = Math.max(res, dfs(i, used));
			}
			
			// Ta da!
			System.out.println(res);
		}
	}
	
	// Run a DFS on v and return the size of the DFS component.
	public static int dfs(int v, boolean[] used) {
	
		/// Mark it.
		int res = 1;
		used[v] = true;
		
		// Recursively go to each unvisited neighbor.
		for (Integer x: g[v])
			if (!used[x])
				res += dfs(x, used);
	
		// Ta da!
		return res;
	}
}