M. Counting in Tree
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given a tree with nodes labeled from $$$1 \sim n$$$, and the root of the tree is vertex $$$1$$$. There are multiple queries, each of which gives one node $$$x$$$, and you need to find $$$$$$ \displaystyle\sum_{u\in T(x)}\displaystyle\sum_{\begin{subarray}{l}v\in T(x)\\ v \lt u\end{subarray}}[\gcd(u,v)=1] $$$$$$ where $$$T(x)$$$ denotes the subtree with root $$$x$$$.

$$$\gcd(u,v)$$$ denotes the greatest common divisor of $$$u$$$ and $$$v$$$.

The value $$$[\ast]$$$ is $$$1$$$ if $$$\ast$$$ is true, otherwise it is $$$0$$$.

Input

The first line contains two integers $$$n,q\ (1\leq n,q\leq 10^5)$$$.

The next line contains $$$n-1$$$ integers, the $$$i$$$-th of which shows the parent node of node $$$i+1$$$.

Each of the next $$$q$$$ lines contains an integer $$$x$$$, which shows the node $$$x$$$ to be queried.

Output

For each query, output your answer as a single integer.

Example
Input
2 2
1
1
2
Output
1
0