Tom is visiting the country Hackerland. Hackerland has n cities and m bi-directional roads. There are k types of tokens. Token i costs ci. The costs of the tokens are such that for all 2≤i≤k, ci≥2ci−1. For each road, you need to have a particular set of tokens, if you want to travel it. Note that you don't have to give the tokens, you just need to show them. Thus, one token can be used at any number of roads, where it is required. Tom wants to select a set of tokens, such that using them, he can go from any city to any other city. You have to help him minimize the total cost of tokens he buys.
Input:
Output:
Constraints
1≤n≤105
1≤m≤105
No road connects a city to the same city. However, there can be multiple roads between two cities.
1≤ci≤1018
For all 2≤i≤k, ci≥2ci−1
The best way for tom is to buy the first three tokens. Using these tokens, he can use the roads 1 and 2, and using the roads he can go from any city to any other city. The minimum cost is therefore 8