An integer M (1 ≤ M ≤ 2000), representing the number of connections.
M lines follow, each containing:
- A string Start_city of up to 16 alphabetical characters (first character uppercase, rest lowercase).
- A time HH:MM representing the departure time (00:00 ≤ HH:MM ≤ 23:59).
- A string Arrival_city of up to 16 alphabetical characters (first character uppercase, rest lowercase).
- A time HH:MM representing the arrival time (00:00 ≤ HH:MM ≤ 23:59, strictly after the departure time).
- An integer price (1 ≤ price ≤ 10000), representing the cost of the connection.
The end of the input is marked by a line containing a zero.

### Example Input:

```
5
Hakodate 08:15 Morioka 12:30 2500
Morioka 14:05 Hakodate 17:30 2500
Morioka 15:30 Hakodate 18:00 3000
Morioka 14:30 Tokyo 17:50 3000
Tokyo 08:30 Morioka 13:35 3000
0
```

### Function Signature:
Write a function f(connections) that takes in the input.
```python
def f(connections: List[Tuple[str, str, str, str, int]]):
    '''
    connections: a list of tuples, each containing:
        - a string representing the start city
        - a string representing the departure time in HH:MM format
        - a string representing the arrival city
        - a string representing the arrival time in HH:MM format
        - an integer representing the price
    '''
```