An integer N (2 ≤ N ≤ 10^5), representing some quantity or size.
An integer M (1 ≤ M ≤ 2 × 10^5), representing some quantity or size.
A list of M tuples (ai, bi, ci), each with three integers:
  - ai (1 ≤ ai < N)
  - bi (1 ≤ bi ≤ N)
  - ci (1 ≤ ci ≤ 10^9)

### Example Input:

```
4 5
1 2 3
2 3 4
3 4 5
1 3 6
2 4 7
```

### Function Signature:
Write a function f(N, M, bridges) that takes in the input.
```
def f(N: int, M: int, bridges: List[Tuple[int, int, int]]):
    '''
    N: an integer
    M: an integer
    bridges: a list of tuples, each containing three integers
    '''
```