SP10645 MYQ7 - The Rail Network Renovation

Description

The beautiful country of Thuvax has an ancient rail network connecting its 'n' cities using 'm' tracks. The King of Thuvax orders the Railway Minister, Poopsie to renovate the whole rail network. Due to Poopsie's past laziness, the tracks are in shambles and so he wants to rebuild(the tracks are functional again) some of the tracks and destruct(therefore, wont be available for usage) the rest completely. The King wants to ensure that all the cities are connected after the whole network is renovated but being a miser, he wants to spend the least amount of money possible. Help Poopsie find out the least amount of money using which the renovation project can be completed.

Input Format

The first line of the input contains the number of test cases 't'(1

Output Format

The ouput consists of t lines. For each test case, print a single line consisting of a single integer that is the least amount of the money required to renovate the whole rail network.