An integer N (2 ≤ N ≤ 1000), representing some quantity or size.
An integer M (1 ≤ M ≤ min(N(N-1),2000)), representing some quantity or size.
M lines follow, each containing three integers a, b, and c:
- a (1 ≤ a ≤ N)
- b (1 ≤ b ≤ N)
- c (-10^9 ≤ c ≤ 10^9)

### Example Input:
```
3 3
1 2 4
2 3 3
1 3 5
```

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