Test cases for Abroads

This is my solution for The Ancient Berland Roads I am not getting why this solution is incorrect. It is passing all the test cases that I have made but I am not getting what are the test cases which my solution is not passing.

Can any one tell me why this solution is incorrect or If what could be the appropriate test cases for it. It would be a great help.

Thanks in advance.

You can generate random test cases here : http://www.spojtoolkit.com/TestCaseGenerator/
And test its output using one of the given solution.

Most of the time you the bug in a few minutes.