Pairing problem graphs

what is wrong in this ???

test cases are failed

@Kartikkhariwal1

can u help me please ?

hey @hg11110000 your code is running for only the sample test case .
and all other test cases are prosucing the wrong error .
have you tried this question with the help of the Disjoint set union ?

@tusharaggarwal272
no…

what is wrong in this ??

seems correct only
via dfs…if i m able to count the number of nodes in each connected component

@hg11110000
5000 1
1893 3230
try for this input your output is coming different from the expected .
expected output :
12497499