题目描述
Background
Linux and OSX users are certainly familiar with software package managers. With a software package manager, you can install a package with a single command, and the manager will help you download the package from the software source, automatically resolve all dependencies (i.e., download and install other packages that the package depends on), and complete all configurations. Tools like apt-get used by Debian/Ubuntu, yum used by Fedora/CentOS, and homebrew available on OSX are all excellent software package managers.
Problem Description
You have decided to design your own software package manager. Inevitably, you need to address the dependency issues between packages. If package $a$ depends on package $b$, then package $b$ must be installed before package $a$. Similarly, if you want to uninstall package $b$, you must also uninstall package $a$.
You have now obtained all the dependency relationships between the packages. Additionally, due to your previous work, except for package $0$, every package in your manager depends on exactly one other package, and package $0$ does not depend on any package. Also, there are no dependency cycles (i.e., there are no $m$ packages $a_1, a_2, \dots, a_m$ where for $i < m$, $a_i$ depends on $a_{i+1}$, and $a_m$ depends on $a_1$).
You are now tasked with writing a dependency resolution program for your software package manager. Based on user feedback, users want to quickly know how many packages' installation statuses will be changed when installing or uninstalling a package (i.e., how many packages will be installed if they are not already installed, or how many packages will be uninstalled if they are already installed). Your task is to implement this functionality.
Note that installing a package that is already installed, or uninstalling a package that is not installed, will not change the installation status of any package, meaning the number of packages whose installation status is changed in such cases is $0$.
Input Format
The first line contains a positive integer $n$, representing the number of packages, numbered from $0$.
The second line contains $n-1$ integers, where the $i$-th integer represents the package number that package $i$ depends on.
The next line contains a positive integer $q$, representing the number of operations. The operations are formatted as follows:
install xmeans to install package $x$uninstall xmeans to uninstall package $x$
Initially, all packages are uninstalled.
For each operation, you need to output the number of packages whose installation status will be changed by this operation, and then apply this operation (i.e., update the installation status you maintain).
Output Format
Output $q$ lines, each containing a single integer, representing the answer for each query.
Sample Input and Output
Sample Input #1
7
0 0 0 1 1 5
5
install 5
install 6
uninstall 1
install 4
uninstall 0
Sample Output #1
3
1
3
2
3
Sample Input #2
10
0 1 2 1 3 0 0 3 2
10
install 0
install 3
uninstall 2
install 7
install 5
install 9
uninstall 9
install 4
install 1
install 9
Sample Output #2
1
3
2
1
3
1
1
1
0
1
Notes
Initially, all packages are in the uninstalled state.
Installing package $5$ requires installing packages $0, 1, 5$.
Subsequently, installing package $6$ only requires installing package $6$. At this point, packages $0, 1, 5, 6$ are installed.
Uninstalling package $1$ requires uninstalling packages $1, 5, 6$. At this point, only package $0$ remains installed.
Next, installing package $4$ requires installing packages $1, 4$. At this point, packages $0, 1, 4$ are installed. Finally, uninstalling package $0$ will uninstall all packages.
Data Range

输入格式
见题面 Input 部分
输出格式
见题面 Output 部分