Why am i getting segmention error

@navin
the problem is you have taken the graph to be 0-based index but the vertices given in the edges are 1-based index. So i think you how to correct it, otherwise you can ask.

while printing answer for cases, do i++.
Also take long long int to avoid WA.

@navin mark the doubt as resolved if you will be able to solve it now, otherwise you may continue to ask your doubt.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.