Lora’s mansion is being invaded by rats. Luckily we can describe the rooms in Lora’s mansion as a rooted tree with N nodes, numbered from 1 to N, with node 1 being the root.
Initially, no node is infested. Various events happen consecutively, each being one of the following 4 types:
The subtree of node X is defined as the set of nodes that contains X as well as any of its direct or indirect successors (see the sample test for better understanding).
Help Lora by writing a program that processes each of the events and correctly computes the answers to all events of type 4.
The first line of the standard input contains a single integer N – the number of nodes in the tree. The second line contains N - 1 numbers, the i-th of which is pi+1 – the father of node i + 1. The third line contains the number of events Q. Each of the following Q lines contains two integers, describing an event in one of the aforementioned formats.
For every event of type 4 output a single line containing one integer – the number of infested nodes in the subtree.
The events have the following effect: