An integer NAB (0 ≤ NAB ≤ 50), representing a quantity.
An integer NBA (0 ≤ NBA ≤ 50), representing another quantity.
A list of NAB tuples, where each tuple contains:
  - An integer Ci (1 ≤ Ci ≤ 10), representing a quantity.
  - An integer Di (0 ≤ Di < 86400), representing a time.
  - An integer Ai (0 ≤ Ai < 86400), representing another time.
A list of NBA tuples, where each tuple contains:
  - An integer Ci (1 ≤ Ci ≤ 10), representing a quantity.
  - An integer Di (0 ≤ Di < 86400), representing a time.
  - An integer Ai (0 ≤ Ai < 86400), representing another time.

### Example Input:

```
1 1
10 100 0
10 100 0
```

### Function Signature:
Write a function f(NAB, NBA, trains_AB, trains_BA) that takes in the input.
def f(NAB: int, NBA: int, trains_AB: List[Tuple[int, int, int]], trains_BA: List[Tuple[int, int, int]]):
    '''
    NAB: an integer
    NBA: an integer
    trains_AB: a list of tuples, where each tuple contains three integers
    trains_BA: a list of tuples, where each tuple contains three integers
    '''