# Road Reparation
## Problem Statement
There are $n$ cities and $m$ roads connecting them. Unfortunately, all existing roads are in a state of disrepair and cannot be used. Your task is to select a subset of these roads to repair such that it is possible to travel between any two cities. Each road has a specific reparation cost, and your goal is to achieve connectivity for all cities with the minimum possible total reparation cost.
If it is impossible to connect all $n$ cities, even by repairing all available roads, you should report that no solution exists.
## Input Format
- First line: two integers, $n$ ($1 \le n \le 10^5$) - the number of cities, and $m$ ($1 \le m \le 2 \times 10^5$) - the number of available roads.
- Each of the next $m$ lines: three integers $a$, $b$, and $c$, indicating a road between city $a$ and city $b$ with a reparation cost of $c$.
- $1 \le a, b \le n$
- $a \ne b$
- $1 \le c \le 10^9$
All roads are two-way. There is at most one road between any two distinct cities.
## Output Format
Print a single integer: the minimum total reparation cost required to connect all cities. If it is impossible to connect all cities, print `IMPOSSIBLE`.
## Sample Test Cases
### Sample Input 1
```
5 6
1 2 3
2 3 5
2 4 2
3 4 8
5 1 7
5 4 4
```
### Sample Output 1
```
14
```
### Sample Input 2
```
3 1
1 2 10
```
### Sample Output 2
```
IMPOSSIBLE
```
## Constraints
- $1 \le n \le 10^5$
- $1 \le m \le 2 \times 10^5$
- $1 \le a, b \le n$
- $a \ne b$
- $1 \le c \le 10^9$
- There is at most one road between any two cities.
- All roads are two-way.
- Time limit: 1 second
- Memory limit: 256 MB
## Explanation
### Sample 1
To connect all 5 cities with minimum cost, we can choose the following roads:
- Road between cities 2 and 4 with cost 2.
- Road between cities 1 and 2 with cost 3.
- Road between cities 5 and 4 with cost 4.
- Road between cities 2 and 3 with cost 5.
These four roads connect all 5 cities (forming a Minimum Spanning Tree). The total cost is $2 + 3 + 4 + 5 = 14$.
### Sample 2
There are 3 cities, but only one road connecting cities 1 and 2. City 3 remains isolated, and there's no way to connect it to cities 1 and 2. Therefore, it's impossible to connect all cities, and the output is `IMPOSSIBLE`.
Loading problem statement...