Fady is managing a road network of cities and bidirectional roads. Currently, all cities are "Standard". Fady must upgrade exactly cities to "VIP" status.
Every road generates a congestion score based on the cities it connects:
1 if it connects two "VIP" cities.
2 if it connects one "VIP" city and one "Standard" city.
3 if it connects two "Standard" cities.
Find the minimum possible total congestion score of all roads after Fady optimally chooses exactly cities to upgrade.
The first line contains an integer (1 \le t \le 10^4) — the number of test cases.
The first line of each test case contains three integers , , and (1 \le k \le n \le 2 \cdot 10^5, 0 \le m \le \min\left(5 \cdot 10^5, \frac{n(n-1)}{2}\right)) — the number of cities, roads, and cities to upgrade to "VIP" status.
The following lines describe the roads. Each line contains two integers and (1 \le u, v \le n, u \ne v) denoting a bidirectional road between city and city .
The graph contains no self-loops or multiple edges.
It is guaranteed that the sum of over all test cases does not exceed 2 \cdot 10^5, and the sum of over all test cases does not exceed 5 \cdot 10^5.
For each test case, output a single integer — the minimum possible total congestion score of the road network after Fady optimally upgrades exactly cities to "VIP" status.
Example 1
In the first sample, the optimal choice is to upgrade city to "VIP" status. The congestion scores for the roads , , , and become , , , and , respectively. The minimum total congestion score is 2 + 3 + 3 + 2 = 10.
Subtask ( points): \sum n \le 20.
Subtask ( points): No additional constraints.