An integer N (1 ≤ N ≤ 1000), representing some quantity or size.
A list of integers P of size (N-1), where each integer is between 1 and (i-1) for 2 ≤ i ≤ N.
A list of integers X of size N, where each integer is between 0 and 5000.

### Example Input:

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

### Function Signature:
Write a function f(N, P, X) that takes in the input.
```python
def f(N: int, P: List[int], X: List[int]):
    '''
    N: an integer
    P: a list of integers
    X: a list of integers
    '''
```