Canonicalized Input Description:

An integer \(N\) (3 ≤ \(N\) ≤ 8), representing some quantity or size.
Three distinct integers \(A\), \(B\), and \(C\) (1 ≤ \(C\) < \(B\) < \(A\) ≤ 1000).
A list of \(N\) integers \(l\), where each integer \(l_i\) (1 ≤ \(l_i\) ≤ 1000).

### Example Input:

```
5 100 90 80
98
40
30
21
80
```

### Function Signature:
Write a function `f(N, (A, B, C), l)` that takes in the input.
```python
def f(N: int, targets: Tuple[int, int, int], lengths: List[int]):
    '''
    N: an integer
    targets: a tuple of three integers
    lengths: a list of integers
    '''
```