Winning the election was simpler than you expected: it was enough to promise to finally build
a good quality, country-wide road infrastructure, of course without crippling the budget_ Your
happiness did not last long, however: it seems, that the citizens have found a way to actually
hold you accountable for your promise!
There are n major cities in your country. The Ministry of Transport has prepared a detailed
map, outlining m possible highway connections, together with their costs. The Quality Assurance
Committee will not let you build a highway cheaper than l, and the National Spendings
Regulatory Committee will not let you build a highway more expensive than h. To claim a
"country-wide" network, you have to connect (possibly indirectly) as many pairs of cities, as it is
possible within these two constraints. You have to find the cheapest way to do it, and you have
to find it quickly! Of all networks that meet the constraints and connect the most pairs of cities,
compute the cost of the cheapest one.
To make things worse, both committees are heavily influenced by your angry competitors:
each time you publish your hard-prepared plan, they immediatelv change their rulings l and矗,
and vou are forced to start from scratch.
有N个点,M条无向虚边(边还未连接上去),Q组询问,询问格式如下:
对于第一个询问输入2个数L1,H1,表示你要用满足权值L1<=Ai<=H1的所有边来连接点使得能互相通达的点的数量最多。在此条件下,输出最小的权值和C1. 对于第i个询问(1
N<=1000, M<=100000, Q<=1000000