An integer \( N \) (3 ≤ \( N \) ≤ 500), representing some quantity.
An integer \( M \) (\( N \)-1 ≤ \( M \) ≤ min(50000, \( N(N-1)/2 \)), representing another quantity.
A list of \( M \) tuples, each containing three integers \( S \), \( D \), and \( C \) (1 ≤ \( S \) < \( D \) ≤ \( N \); 1 ≤ \( C \) ≤ 10000).

### 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, each containing three integers
    '''
```