After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.

Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of *n* nodes. The root of tree has index 1. Kay is very interested in the structure of this tree.

After doing some research he formed *q* queries he is interested in. The *i*-th query asks to find a centroid of the subtree of the node *v*<sub class="lower-index">*i*</sub>. Your goal is to answer all queries.

Subtree of a node is a part of tree consisting of this node and all it's descendants (direct or not). In other words, subtree of node *v* is formed by nodes *u*, such that node *v* is present on the path from *u* to root.

Centroid of a tree (or a subtree) is a node, such that if we erase it from the tree, the maximum size of the connected component will be at least two times smaller than the size of the initial tree (or a subtree).
The first line of the input contains two integers *n* and *q* (2 ≤ *n* ≤ 300 000, 1 ≤ *q* ≤ 300 000) — the size of the initial tree and the number of queries respectively.

The second line contains *n* - 1 integer *p*<sub class="lower-index">2</sub>, *p*<sub class="lower-index">3</sub>, ..., *p*<sub class="lower-index">*n*</sub> (1 ≤ *p*<sub class="lower-index">*i*</sub> ≤ *n*) — the indices of the parents of the nodes from 2 to *n*. Node 1 is a root of the tree. It's guaranteed that *p*<sub class="lower-index">*i*</sub> define a correct tree.

Each of the following *q* lines contain a single integer *v*<sub class="lower-index">*i*</sub> (1 ≤ *v*<sub class="lower-index">*i*</sub> ≤ *n*) — the index of the node, that define the subtree, for which we want to find a centroid.
The first query asks for a centroid of the whole tree — this is node 3. If we delete node 3 the tree will split in four components, two of size 1 and two of size 2.

The subtree of the second node consists of this node only, so the answer is 2.

Node 3 is centroid of its own subtree.

The centroids of the subtree of the node 5 are nodes 5 and 6 — both answers are considered correct.
7 4
1 1 3 3 5 3
1
2
3
5
3
2
3
6
2 2
1
1
2
2
2

class Node:
    def __init__(self, id):
        self.id = id + 1
        self.children = []
        self.parent = None
        self.subtree_size = 1
        self.parent_graph_size = 0

    def calc_subtree_size(self):
        self.subtree_size = 1
        for child in self.children:
            child.calc_subtree_size()
            self.subtree_size += child.subtree_size

    def calc_parent_graph_size(self):
        if self.parent:
            self.parent_graph_size = self.parent.subtree_size - self.subtree_size

    def __str__(self):
        return "id: {}, parent: {}, children: {}".format(self.id, self.parent.id if self.parent else "None", [c.id for c in self.children])


def main():
    graph, queries = load()
    # for g in graph:
    #     print(g)

    for node in graph:
        node.calc_subtree_size()

    for node in graph:
        node.calc_parent_graph_size()

    # print("=====")
    for q in queries:
        # print("{} -- {}".format(q+1, get_centroid(graph[q])))
        print(get_centroid(graph[q]).id)


def load():
    n, query_count = [int(x) for x in input().strip().split()]

    graph = [Node(i) for i in range(n)]
    Vs = [int(x) for x in input().strip().split()]

    for i, v in enumerate(Vs):
        graph[i+1].parent = graph[v-1]
        graph[v-1].children.append(graph[i+1])

    queries = [int(input()) - 1 for _ in range(query_count)]
    return graph, queries


def get_centroid(root):
    queue = [root]
    while queue:
        node = queue.pop(0)
        if is_centroid(root, node):
            return node
        queue.extend(node.children)


def is_centroid(root, node):
    threshold = root.subtree_size // 2
    for child in node.children:
        if child.subtree_size > threshold:
            return False
    return node.parent_graph_size - root.parent_graph_size <= threshold


main()