There are no more than 6 test cases.
For each test case there are two positive integers n and q, indicate that the tree has n nodes and you need to answer q queries.
Then two lines follow.
The first line contains n non-negative integers $V_1,V_2,\cdots,V_n$, indicating the value of node i.
The second line contains n-1 non-negative integers $F_1,F_2,\cdots\,F_{n-1}$, $F_i$ means the father of node $i+1$.
And then q lines follow.
In the i-th line, there are two integers u and x, indicating that the node you pick should be in the subtree of u, and x has been described in the problem.
$2 \leq n,q \leq 10^5$
$0 \leq V_i \leq 10^9$
$1 \leq F_i \leq n$, the root of the tree is node 1.
$1 \leq u \leq n,0 \leq x \leq 10^9$