$$$~\\$$$
Neuro-sama and Evil are planning to build houses on a tree. The tree has $$$n$$$ nodes and $$$n-1$$$ edges. Each node is capable of hosting exactly one room, and together these rooms will form the house.
Evil, always overflowing with ideas, has drafted $$$q$$$ different construction plans. In each plan, she selects a set of nodes $$$S$$$, and places one room on every node in $$$S$$$. However, her sister Neuro has a rather strict aesthetic sense. For her, a construction plan is considered elegant only if all rooms form a single connected area — that is, for any two nodes $$$u, v \in S$$$, there exists a path between $$$u$$$ and $$$v$$$ entirely within $$$S$$$.
To keep the peace (and prevent Evil from storming off to draft even stranger structures), Neuro asks for your help: for each of the $$$q$$$ plans, determine whether the plan is elegant.
The first line contains two integers $$$n$$$ and $$$q$$$ $$$(1\le n, q\le 5\cdot 10^{5})$$$.
The next line contains $$$n-1$$$ integers $$$p_2,p_3,\dots,p_n$$$ $$$(1\le p_i\le n)$$$, where $$$p_i$$$ is the parent of the $$$i$$$-th vertex in the tree. Vertex $$$1$$$ is the root.
Then $$$q$$$ lines follow. Each line begins with an integer $$$k$$$ $$$(1 \le k \le n)$$$, followed by $$$k$$$ distinct integers $$$s_1, s_2, \dots, s_k$$$ $$$(1 \le s_i \le n;\ \forall i\neq j, s_i\neq s_j)$$$, representing the selected nodes.
It is guaranteed that the sum of $$$k$$$ over all queries does not exceed $$$5\cdot 10^{5}$$$.
For each query, output "Yes" if the plan is elegant or "No" if not.
You can output "Yes" and "No" in any case (for example, strings "yEs", "yes", and "YES" will be recognized as a positive response).
5 21 2 2 12 1 23 5 4 3
Yes No