An integer n (3 ≤ n ≤ 100), an integer m (2 ≤ m ≤ 1000), an integer s (1 ≤ s ≤ n), and two distinct integers g1 and g2 (1 ≤ g1, g2 ≤ n). Followed by m lines, each containing three integers b1, b2 (1 ≤ b1, b2 ≤ n, b1 ≠ b2), and c (1 ≤ c ≤ 1000). Input ends with a line containing five zeros.

### Example Input:

```
4 5 1 3 4
1 2 5
2 3 5
2 4 5
1 3 8
1 4 8
0 0 0 0 0
```

### Function Signature:
Write a function f(inputs) that takes in the input as a list of tuples.
def f(inputs: List[Tuple[int, int, int, int, int, List[Tuple[int, int, int]]]]): 
    ''' 
    inputs: a list of tuples
    '''