Where is the problem in my code?

Hello, can someone please help me. I do not see, where my error is. The link of the excercise is this one: CodeChef

class Codechef
{
    private static LinkedList<Integer>[] nodes;
	public static void main (String[] args) throws java.lang.Exception
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String str1 = br.readLine();
        int numberOfTests = Integer.parseInt(str1);
        for(int x=0;x<numberOfTests;x++) {
            String[] str2 =br.readLine().split(" ");
            int numberOfLevels = Integer.parseInt(str2[0]);
            int numberOfEdges = Integer.parseInt(str2[1]);
            
            if(numberOfLevels<=0 || numberOfEdges <0)
                {
                    System.out.println("No");
                    return;
                }

            nodes = new LinkedList[numberOfLevels];

            //init adj. list
            for (int i = 0; i < numberOfLevels; i++) {
                nodes[i] = new LinkedList();
            }

            for (int i = 0; i < numberOfEdges; i++) {
                String[] str = br.readLine().split(" ");
                int from = Integer.parseInt(str[1]);
                int to = Integer.parseInt(str[0]);
                nodes[to].add(from);
            }
            int result = topSort(numberOfLevels);
            if (result != numberOfLevels) {
                System.out.println("No");
            } else {
                System.out.println("Yes");
            }
        }
	}
 private static int topSort(int numberOfNodes){
        int[] indegree = new int[numberOfNodes];
        boolean[] visited = new boolean[numberOfNodes];
        ArrayList<Integer> res = new ArrayList<>();


        //calc indegree;
        for(int i = 0;i<numberOfNodes;i++){
            for(int j = 0; j<nodes[i].size();j++){
                int n = nodes[i].get(j);
                indegree[n] = indegree[n]+1;
            }
        }
        PriorityQueue<Integer> pq = new PriorityQueue<>();
        for(int i=0;i<numberOfNodes;i++){
            if(indegree[i]==0) {
               pq.add(i);
            }

        }





            while (!pq.isEmpty()) {
                int cur = pq.poll();
                res.add(cur);
                for (Integer i : nodes[cur]) {
                    indegree[i] = indegree[i] - 1;
                    if (indegree[i] == 0) {
                        pq.add(i);
                    }
                }
            }

        return res.size();
    }
   
}

What is happening
TLE, WA, RE or CE?