An integer N (1 ≤ N ≤ 1000), representing some quantity or size.
An integer M (1 ≤ M ≤ 10000), representing some quantity or size.
An integer r (2 ≤ r ≤ 1000), representing some quantity or size.
A list of r tuples, each containing four integers t, n, m, s where:
  - 540 ≤ t ≤ 1260
  - 1 ≤ n ≤ N
  - 1 ≤ m ≤ M
  - s is either 0 or 1
An integer q (1 ≤ q ≤ 50), representing some quantity or size.
A list of q tuples, each containing three integers ts, te, m where:
  - 540 ≤ ts < te ≤ 1260
  - 1 ≤ m ≤ M

### Example Input:
```
4 2
10
775 1 1 1
780 4 2 1
790 2 1 1
800 2 1 0
810 3 1 1
820 1 1 0
825 3 1 0
860 1 1 1
870 4 2 0
880 1 1 0
1
780 870 1
```

### Function Signature:
Write a function f(inputs) that takes in the input.
def f(inputs: List[Tuple[int, int, int, List[Tuple[int, int, int, int]], int, List[Tuple[int, int, int]]]]):
    '''
    inputs: a list of tuples where each tuple contains:
      - A tuple of three integers (N, M, r)
      - A list of r tuples each containing four integers (t, n, m, s)
      - An integer q
      - A list of q tuples each containing three integers (ts, te, m)
    '''