An integer X (1 ≤ X ≤ 1000), representing some quantity.
An integer Y (1 ≤ Y ≤ 1000), representing some quantity.
An integer Z (1 ≤ Z ≤ 1000), representing some quantity.
An integer K (1 ≤ K ≤ min(3000, X * Y * Z)), representing some quantity.
A list of X integers, where each integer is between 1 and 10^10.
A list of Y integers, where each integer is between 1 and 10^10.
A list of Z integers, where each integer is between 1 and 10^10.

### Example Input:

```
2 2 2 8
4 6
1 5
3 8
```

### Function Signature:
Write a function f(X, Y, Z, K, A, B, C) that takes in the input.
def f(X: int, Y: int, Z: int, K: int, A: List[int], B: List[int], C: List[int]):
    '''
    X: an integer
    Y: an integer
    Z: an integer
    K: an integer
    A: a list of integers
    B: a list of integers
    C: a list of integers
    '''