Problem: Danil decided to earn some money, so he had found a part-time job. The interview have went well, so now he is a light switcher.

Danil works in a rooted tree (undirected connected acyclic graph) with n vertices, vertex 1 is the root of the tree. There is a room in each vertex, light can be switched on or off in each room. Danil's duties include switching light in all rooms of the subtree of the vertex. It means that if light is switched on in some room of the subtree, he should switch it off. Otherwise, he should switch it on.

Unfortunately (or fortunately), Danil is very lazy. He knows that his boss is not going to personally check the work. Instead, he will send Danil tasks using Workforces personal messages.

There are two types of tasks: 

  1. pow v describes a task to switch lights in the subtree of vertex v.
  2. get v describes a task to count the number of rooms in the subtree of v, in which the light is turned on. Danil should send the answer to his boss using Workforces messages.



A subtree of vertex v is a set of vertices for which the shortest path from them to the root passes through v. In particular, the vertex v is in the subtree of v.

Danil is not going to perform his duties. He asks you to write a program, which answers the boss instead of him.

Input

The first line contains a single integer n (1 ≤ n ≤ 200 000) — the number of vertices in the tree.

The second line contains n - 1 space-separated integers p2, p3, ..., pn (1 ≤ pi < i), where pi is the ancestor of vertex i.

The third line contains n space-separated integers t1, t2, ..., tn (0 ≤ ti ≤ 1), where ti is 1, if the light is turned on in vertex i and 0 otherwise.

The fourth line contains a single integer q (1 ≤ q ≤ 200 000) — the number of tasks.

The next q lines are get v or pow v (1 ≤ v ≤ n) — the tasks described above.

Output

For each task get v print the number of rooms in the subtree of v, in which the light is turned on.

Example

Input

4
1 1 1
1 0 0 1
9
get 1
get 2
get 3
get 4
pow 1
get 1
get 2
get 3
get 4


Output

2
0
0
1
2
1
1
0

Note

<image> The tree before the task pow 1.

<image> The tree after the task pow 1.

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
const int MAX = 200200;
int n, pot;
int first[4 * MAX], type[4 * MAX];
bitset<4 * MAX> updated;
void init() {
  for (int i = pot - 1; i >= 1; i--) first[i] = first[2 * i] + first[2 * i + 1];
}
void sub_update(int node, int l, int r) {
  if (!updated[node]) {
    if (type[node] == 0)
      first[node] = 0;
    else if (type[node] == 1)
      first[node] = (r - l + 1);
    else
      first[node] = (r - l + 1) - first[node];
    updated[node] = true;
    if (node < pot) {
      if (updated[2 * node] || type[node] == 0 || type[node] == 1) {
        updated[2 * node] = false;
        type[2 * node] = type[node];
      } else {
        if (type[2 * node] == 2)
          updated[2 * node] = true;
        else {
          updated[2 * node] = false;
          type[2 * node] = (type[2 * node] + 1) % 2;
        }
      }
      if (updated[2 * node + 1] || type[node] == 0 || type[node] == 1) {
        updated[2 * node + 1] = false;
        type[2 * node + 1] = type[node];
      } else {
        if (type[2 * node + 1] == 2)
          updated[2 * node + 1] = true;
        else {
          updated[2 * node + 1] = false;
          type[2 * node + 1] = (type[2 * node + 1] + 1) % 2;
        }
      }
    }
  }
}
int query(int node, int l, int r, int L, int R) {
  sub_update(node, l, r);
  if (R < l || r < L)
    return 0;
  else if (L <= l && r <= R) {
    return first[node];
  } else
    return query(2 * node, l, (l + r) / 2, L, R) +
           query(2 * node + 1, (l + r) / 2 + 1, r, L, R);
}
void update(int node, int l, int r, int L, int R, int t) {
  sub_update(node, l, r);
  if (R < l || r < L)
    return;
  else if (L <= l && r <= R) {
    updated[node] = false;
    type[node] = t;
    sub_update(node, l, r);
  } else {
    update(2 * node, l, (l + r) / 2, L, R, t);
    update(2 * node + 1, (l + r) / 2 + 1, r, L, R, t);
    first[node] = first[2 * node] + first[2 * node + 1];
  }
}
vector<int> adj[MAX];
int cnt;
int ini[MAX], fn[MAX];
void dfs(int u, int p) {
  ini[u] = cnt++;
  for (__typeof((adj[u]).begin()) v = (adj[u]).begin(); v != (adj[u]).end();
       v++)
    if (*v != p) dfs(*v, u);
  fn[u] = cnt - 1;
}
char s[100];
int main() {
  scanf("%d", &n);
  for (int i = 0; i < int(n - 1); i++) {
    int p;
    scanf("%d", &p);
    p--;
    adj[p].push_back(i + 1);
    adj[i + 1].push_back(p);
  }
  cnt = 0;
  dfs(0, -1);
  updated.set();
  pot = 1;
  while (pot < n) pot *= 2;
  for (int i = 0; i < int(n); i++) scanf("%d", &first[pot + ini[i]]);
  init();
  int Q;
  scanf("%d", &Q);
  for (int q = 0; q < int(Q); q++) {
    int u;
    scanf("%s %d", s, &u);
    u--;
    if (s[0] == 'g') printf("%d\n", query(1, 0, pot - 1, ini[u], fn[u]));
    if (s[0] == 'p') update(1, 0, pot - 1, ini[u], fn[u], 2);
  }
}