Professor Zhang has heard that the longest path problem cannot be solved in polynomial time for arbitrary graphs unless P = NP. Now, Professor Zhang would like to solve this problem in polynomial time in some graphs.
The longest path problem is the problem of finding a simple path of maximum length in a given graph. A path is called simple if it does not have any repeated vertices. The length of a path is the number of edges in this path.
There are multiple test cases. The first line of input contains an integer T (about 350) indicating the number of test cases. For each test case:
The first line contains two integers n and m (3≤n≤104, n≤m≤n+4): the number of vertices and the number of edges.
Each of the following m lines contains two integers a_i and b_i which denotes an edge between vertices a_i and b_i (1≤a_i,b_i≤n, a_i=b_i).
It is guaranteed that the graph is connected and does not contain multiple edges.
The total size of the input is at most 4 mebibytes.
For each test case, output an integer denoting the length of the longest path.