Given a tree with $n$ vertices, labeled $1, \dots, n$, and a sequence $a_1, \dots, a_{n_0}$ of length $n_0$, there are $m$ queries. Each query provides $l, r, x$, and asks for the vertex reached by starting at vertex $x$ and moving one step towards each of $a_l, \dots, a_r$ in sequence.
If $x = y$, moving one step from $x$ towards $y$ results in $x$. Otherwise, it results in the vertex adjacent to $x$ that is closest to $y$ in the tree.
Input
The first line contains three integers $n, n_0, m$.
The next line contains $n-1$ integers representing $f_2, \dots, f_n$, where $f_i$ is the parent of vertex $i$, and $1$ is the root.
The next line contains $n_0$ integers, representing $a_1, \dots, a_{n_0}$.
The next $m$ lines each contain three integers $l \oplus v, r \oplus v, x \oplus v$, representing a query, where $v$ is the answer to the previous query (for the first query, $v = 0$), and $\oplus$ is the bitwise XOR operator.
Output
Output $m$ lines, each containing the answer to the corresponding query.
Examples
Input 1
5 4 3 1 1 3 3 5 2 2 3 3 4 5 2 0 7 3 0 3
Output 1
3 2 1
Subtasks
Idea: Ynoi, Solution: ccz181078, Code: ccz181078, Data: ccz181078
For $100\%$ of the data, $1 \le n, n_0, m \le 10^5$.
For $25\%$ of the data, $n, n_0, m \le 10^3$.
For $25\%$ of the data, $f_i = i-1$.
For $25\%$ of the data, $f_i$ is chosen uniformly at random from $1, 2, \dots, i-1$.