Kamar-taj is a place where "The Acient One" trains people to protect earth from other dimensions.
The earth is protected by 'n' sanctums, destroying any of it will lead to invasion on earth.
The sanctums are connected by 'm' bridges.
Now , you being on dormammu's side , want to finds no of sanctum destroying which will disconnect the sanctums.
Input:
First line of the input contains T the number of test cases.
First line of each test case contains n(no of sanctums) and m(no of bridges).
Each m line of test case contains p and q denoting sanctum p is connected to sanctum q.
Output:
Each new line of the output contains no of sanctums when destroyed will disconnect other sanctums of Earth .
Constraints:
1 ≤ T ≤ 100
1 ≤ n ≤ 30000
1 ≤ m ≤ 30000
1 ≤ p,q ≤ n
Example:Input:
1
5 5
1 2
1 3
3 2
3 4
5 4
Output:
2
classGFG {// Function to count number of articulation points// In undirected connected graphstaticint[] low, discovery;staticint time, count;publicstaticintfindArticulationPoints(List<Integer>[] graph,int n) {boolean visited[] =newboolean[n];// Starting DFS from 0th vertex low =newint[n]; discovery =newint[n]; time =0; count =0;DFS(graph,0,-1, visited);return count; }publicstaticvoidDFS(List<Integer>[] graph,int node,int parent,boolean[] visited) { low[node] = time; discovery[node] = time; time++; visited[node] =true;int dfsCalls =0;boolean isAP =false;for (int neighbor : graph[node]) {if (neighbor == parent)continue;if (visited[neighbor]) low[node] =Math.min(low[node], discovery[neighbor]);else {DFS(graph, neighbor, node, visited); low[node] =Math.min(low[node], low[neighbor]);if (discovery[node] <= low[neighbor] &&!isAP && node !=0) { isAP =true; count++; } dfsCalls++; } }// 0th node is our startng point, therefore with above formula it will always be// AP// which might not be true, therefore we check the number of components// connected to this node// Therefore if components>=2, then this node will also be an APif (node ==0&& dfsCalls >1) { count++; } }publicstaticvoidmain(String[] args) {Scanner s =newScanner(System.in);int t =s.nextInt();while (t-->0) {int n =s.nextInt();List<Integer>[] graph =newArrayList[n];for (int i =0; i < n; i++) graph[i] =newArrayList<>();int e =s.nextInt();for (int i =0; i < e; i++) {int u =s.nextInt() -1;int v =s.nextInt() -1; graph[u].add(v); graph[v].add(u); }System.out.println(findArticulationPoints(graph, n)); }s.close(); }}