Canonicalized Input Description:

An integer n (2 ≤ n ≤ 100000), representing some quantity or size.
A list of n elements, where each element is a list starting with an integer k_i (0 ≤ k_i < n) followed by k_i integers, each representing an ID (0 ≤ ID < n).
An integer q (2 ≤ q ≤ 200000), representing some quantity or size.
A list of q elements, where each element is either:
- a list [0, v, w] with integers v (1 ≤ v ≤ n-1) and w (1 ≤ w ≤ 10000)
- or a list [1, u] with an integer u (1 ≤ u ≤ n-1)

### Example Input:

```
6
2 1 2
2 3 5
0
0
0
1 4
7
1 1
0 3 10
1 2
0 4 20
1 3
0 5 40
1 4
```

### Function Signature:
Write a function f(n, node_info, q, queries) that takes in the input.
def f(n: int, node_info: List[List[int]], q: int, queries: List[List[int]]):
    '''
    n: an integer
    node_info: a list of lists of integers
    q: an integer
    queries: a list of lists of integers
    '''