An integer \( q \) (1 ≤ \( q \) ≤ 200,000), representing some quantity or size.
A list of \( q \) queries, where each query is either:
- Two integers (0 ≤ x ≤ 1,000,000,000) representing an operation and a value.
- Three integers (0 ≤ L ≤ 1,000,000,000, 0 ≤ R ≤ 1,000,000,000) representing an operation and a range.

### Example Input:

```
9
0 1
0 2
0 3
2 2
1 1
1 2
1 3
0 4
3 2 4
```

### Function Signature:
Write a function f(queries) that takes in the input.
def f(queries: List[Tuple[int, Union[int, Tuple[int, int]]]]):
    '''
    queries: a list of queries where each query is either a tuple of two integers or a tuple of three integers
    '''
