An integer A (1 ≤ A ≤ 10^5), representing some quantity.
An integer B (1 ≤ B ≤ 10^5), representing some quantity.
An integer M (1 ≤ M ≤ 10^5), representing some quantity.
A list of integers of size A, where each integer is between 1 and 10^5.
A list of integers of size B, where each integer is between 1 and 10^5.
M tuples, each containing three integers. The first integer is in the range [1, A], the second integer is in the range [1, B], and the third integer is between 1 and 10^5.

### Example Input:

```
3 3 1
3 3 3
3 3 3
1 2 1
```

### Function Signature:
Write a function f(A, B, M, list_A, list_B, discounts) that takes in the input.
```python
def f(A: int, B: int, M: int, list_A: List[int], list_B: List[int], discounts: List[Tuple[int, int, int]]):
    '''
    A: an integer
    B: an integer
    M: an integer
    list_A: a list of integers
    list_B: a list of integers
    discounts: a list of tuples, each containing three integers
    '''
```