An integer \(N\) (3 ≤ \(N\) ≤ 500), representing some quantity or size.
An integer \(M\) (N-1 ≤ \(M\) ≤ min(50000, \(N(N−1)/2\))), representing another quantity or size.
A list of \(M\) tuples \((S_i, D_i, C_i)\), where each tuple consists of:
- An integer \(S_i\) (1 ≤ \(S_i\) < \(D_i\) ≤ \(N\)), representing some quantity or size.
- An integer \(D_i\) (1 ≤ \(S_i\) < \(D_i\) ≤ \(N\)), representing some quantity or size.
- An integer \(C_i\) (1 ≤ \(C_i\) ≤ 10000), representing some quantity or size.

### Example Input:

```
4 4
1 2 3
1 3 3
2 3 3
2 4 3
```

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