Passing all the test cases but not accepted

import java.util.*;

public class Main
{
public static void main(String [] args)
{
Scanner scn = new Scanner(System.in);

    int n = scn.nextInt();
    int m = scn.nextInt();
    
    //directed graph
    HashMap <Integer, HashSet<Integer>> graph = new HashMap <> ();

    
    for(int i = 1; i<=m; i++)
    {
        int x = scn.nextInt();
        int y = scn.nextInt();
        

		if(!graph.containsKey(x))
			graph.put(x, new HashSet <Integer> ());

		if(!graph.containsKey(y))
			graph.put(y, new HashSet <Integer> ());


        
        //directed graph
        //directed from smaller value
        //node to larger valued node
        if(x <= y)
        {
			graph.get(x).add(y);
        }
        else
        {
            graph.get(y).add(x);
        }
    }
    
    
    
    System.out.println(beautifulVertices(graph));
}




public static long beautifulVertices(HashMap <Integer, HashSet<Integer>>graph)
{
    HashMap <Integer, Boolean> visited = new HashMap <> ();
    
    long finalAns = 0; int ans = 0;
    
    
    for(int i : graph.keySet())
    {
        if(visited.containsKey(i))
            continue;
            
        //apply bfs
        Queue <Integer> q = new LinkedList <> ();
        
        //adding the parent vertex of the component
        q.add(i);
        
        ans = 0;
        
        while(!q.isEmpty())
        {
            int rv = q.remove();
            
            if(visited.containsKey(rv))
                continue;
                
            visited.put(rv,true);
            
            
            //no. of children for 
            //rv, if rv is considered
            //the current parent then,
            //removed vertex children
            int rvc = graph.get(rv).size();
            
            
            for(int nbr : graph.get(rv))
            {
                if(visited.containsKey(nbr))
                    continue;
                
                //no. of children for current vertex
                //current vertex children
                int cvc = graph.get(nbr).size();
                
                if(cvc > rvc)
                    ans++;
                
                q.add(nbr);
            }
            
            
        }
        
        finalAns += ans;
    }
    
    return finalAns;
}

}

what error is the compiler showing?

During submission, I am getting wrong answer

for the sample test case given in the problem, it is working.

please tell me the test case number that is giving wrong answer. I can give you the test case input which you can dry run then and check why your code is coming wrong

yeah there are two test cases

both of them are giving wrong answers. Please provide the test cases

send me your email id via chat feature i will send you the files over there

Can you reply a little faster? This is an instant doubt support i guess

you should check on the chat as that is where I received your mail id

i didn’t receive the test cases. Please help fast! its been two days

check again in your inbox

dry run test case 1 to see if that helps

Sir, how can i dry run such a big test case?

by dry run i mean run on your local compiler and check what value your code is outputting

hi
Sir i think i should recode the question one more time.
I’ll Inform you

Okay do it I will update you if anything happens