After a hectic week at work, Mancunian and Liverbird decide to go on a fun weekend camping trip. As they were passing through a forest, they stumbled upon a unique tree of nodes. Vertices are numbered from to .
Each node of the tree is assigned a color (out of possible colors). Being bored, they decide to work together (for a change) and test their reasoning skills. The tree is rooted at vertex . For each node, they want to find its closest ancestor having the same color.
The first line contains two integers and denoting the number of vertices in the tree and the number of possible colors.
The second line contains integers. The -th integer denotes the parent of the - th vertex.
The third line contains integers, denoting the colors of the vertices. Each color lies between and inclusive.
Print integers. The -th integer is the vertex number of lowest ancestor of the -th node which has the same color. If there is no such ancestor, print for that node.