An integer N (2 ≤ N ≤ 1000), representing some quantity or size.
An integer M (1 ≤ M ≤ min(N(N-1), 2000)), representing some other quantity or size.
A list of M tuples, where each tuple contains two integers and one more integer, all three of which are between -10^9 and 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.
def f(N: int, M: int, edges: List[Tuple[int, int, int]]):
    '''
    N: an integer
    M: an integer
    edges: a list of tuples, where each tuple contains three integers
    '''