A company has N employees, numbered 0 to N-1. The boss of the company is employee 0, while every other employee i has a direct superior Pi. Since employee 0 has no direct superior, P0 = -1. Each employee i starts with an initial salary of Si dollars.
There will be a total of Q operations that you have to handle, each of them being one of two types:
The first line of input will contain two integers, N and Q.
The next line of input will contain N integers, indicating the array P.
The next line of input will contain N integers, indicating the array S.
The next Q lines of input will describe one operation each, in the following formats:
The output should contain one line with one integer for each query operation, indicating the current salary of the requested employee.
1 ≤ N, Q ≤ 106.
0 ≤ Pi < i, for all 1 ≤ i < N.
0 ≤ x < N
0 ≤ d, Si ≤ 109.
5 5 -1 0 0 1 1 1 3 2 3 2 0 1 3 1 4 0 0 2 1 1 1 3
5 8 8
Subtask | Score |
---|---|
1 | 100 |
2 | 0 |