Write a program that determines for two nodes of a tree whether the first one is a parent of another.
The first line contains the number of vertices in a tree. The second line contains numbers, the -th one gives the vertex number of direct ancestor for the vertex . If this value is zero, then the vertex is a root of a tree.
The third line contains the number of queries . Each of the next lines contains two different numbers and .
For each of the queries print on a separate line number , if the vertex is one of the parents of a vertex , and otherwise.