import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.util.Scanner;

import java.util.StringTokenizer;

public class ConnectingNode {

```
static int[][] a;
static int n, m;
static int[] degree;
static boolean[] visited;
public static void main(String[] args) {
// TODO Auto-generated method stub
try(BufferedReader bf = new BufferedReader(new InputStreamReader(System.in))){
Scanner in = new Scanner(System.in);
int testCase = in.nextInt();
for(int t = 1; t <= testCase; t++){
n = in.nextInt();
m = in.nextInt();
a = new int[n][n];
degree = new int[n];
visited = new boolean[n];
for(int i = 0; i < m; i++){
int p = in.nextInt();
int q = in.nextInt();
a[p-1][q-1] = 1;
a[q-1][p-1] = 1;
degree[p-1]++;
degree[q-1]++;
}
if(isEven()){
if(isConnected()){
System.out.println("Case "+t+": Yes");
}else{
System.out.println("Case "+t+": No");
}
}else{
System.out.println("Case "+t+": No");
}
//System.out.println("Case "+t+": "+(isEven()?(isConnected()?"Yes":"No"):"No"));
}
}catch(IOException exc){
System.out.println(exc);
}
}
static void dfs(int dest){
visited[dest] = true;
for(int i = 0; i < n; i++){
if(!visited[i]&a[dest][i]==1){
dfs(i);
}
}
}
static boolean isEven(){
for(int i = 0; i < n; i++){
if(degree[i]%2!=0){
return false;
}
}
return true;
}
static boolean isConnected(){
dfs(0);
for(int i = 0; i < n ; i++){
if(!visited[i]){
return false;
}
}
return true;
}
```

}

Problem

Please help me… I got stuck…