Given a rooted tree with $n$ nodes, where the $i$-th node has a weight $a_i$.
The tree supports the following type of query:
- Given a node $u$ and a parameter $x$, suppose the weights of all nodes are increased by $x$. In this case, find: the maximum possible sum of weights for all connected subgraphs that are entirely contained within the subtree of $u$ and include $u$.
Input
The first line contains two positive integers $n$ and $m$.
The second line contains $n-1$ positive integers $f_2, f_3, \dots, f_n$, which are the parent node indices of $2, 3, \dots, n$ respectively, where it is guaranteed that $1 \le f_i < i$.
The third line contains $n$ integers $a_1, a_2, \dots, a_n$, which are the weights of nodes $1, 2, \dots, n$ respectively.
The next $m$ lines each contain a positive integer $u$ and an integer $x$, representing a query, where it is guaranteed that $1 \le u \le n$.
Output
Output $m$ lines, each containing an integer representing the answer to the corresponding query.
Examples
Input 1
10 6
1 1 2 2 3 5 5 5 6
5 2 3 1 -5 -7 1 1 1 2
1 0
1 -2
1 3
2 1
5 0
5 -2
Output 1
11
4
34
7
-2
-7
Subtasks
Idea: w33z8kqrqk8zzzx33, Solution: w33z8kqrqk8zzzx33 & ccz181078, Code: w33z8kqrqk8zzzx33, Data: w33z8kqrqk8zzzx33
For $100\%$ of the data, $1 \le n, m \le 10^6$, $|a_i|, |x| \le 10^8$, and $1 \le u \le n$.