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>
const int maxn = 200000 + 10;
int id[maxn], top[maxn], rk[maxn], depth[maxn], son[maxn], size[maxn],
    father[maxn];
int N, M, tot, cnt, arr[maxn];
struct Node {
  int v;
  Node* next;
};
struct T {
  int num, lazy;
};
T seg[maxn << 2];
Node pool[maxn], *h[maxn];
inline void add(int u, int v) {
  Node* p = &pool[tot++];
  p->v = v, p->next = h[u], h[u] = p;
}
void dfs1(int u) {
  size[u] = 1, depth[u] = depth[father[u]] + 1;
  for (Node* p = h[u]; p; p = p->next) {
    dfs1(p->v);
    size[u] += size[p->v];
    if (size[son[u]] < size[p->v]) {
      son[u] = p->v;
    }
  }
}
void dfs2(int u, int tp) {
  id[u] = ++cnt, top[u] = tp, rk[cnt] = u;
  if (son[u]) dfs2(son[u], tp);
  for (Node* p = h[u]; p; p = p->next) {
    if (p->v == son[u]) continue;
    dfs2(p->v, p->v);
  }
}
inline void pushdown(int l, int r, int cur) {
  if (seg[cur].lazy) {
    int mid = (l + r) >> 1;
    seg[cur << 1].num = (mid - l + 1 - seg[cur << 1].num);
    seg[cur << 1 | 1].num = (r - mid - seg[cur << 1 | 1].num);
    seg[cur << 1].lazy ^= 1;
    seg[cur << 1 | 1].lazy ^= 1;
    seg[cur].lazy = 0;
  }
}
inline void update(int l, int r, int L, int R, int cur) {
  if (l >= L && r <= R) {
    seg[cur].num = (r - l + 1 - seg[cur].num);
    seg[cur].lazy ^= 1;
    return;
  }
  int mid = (l + r) >> 1;
  pushdown(l, r, cur);
  if (mid >= L) {
    update(l, mid, L, R, cur << 1);
  }
  if (mid < R) {
    update(mid + 1, r, L, R, cur << 1 | 1);
  }
  seg[cur].num = seg[cur << 1].num + seg[cur << 1 | 1].num;
}
inline int query(int l, int r, int L, int R, int cur) {
  if (l >= L && r <= R) {
    return seg[cur].num;
  }
  int mid = (l + r) >> 1;
  pushdown(l, r, cur);
  int ans = 0;
  if (mid >= L) {
    ans += query(l, mid, L, R, cur << 1);
  }
  if (mid < R) {
    ans += query(mid + 1, r, L, R, cur << 1 | 1);
  }
  return ans;
}
void build(int l, int r, int cur) {
  if (l == r) {
    seg[cur].num = arr[rk[l]];
    return;
  }
  int mid = (l + r) >> 1;
  build(l, mid, cur << 1);
  build(mid + 1, r, cur << 1 | 1);
  seg[cur].num = seg[cur << 1].num + seg[cur << 1 | 1].num;
}
inline long long read() {
  long long f = 1, r = 0;
  char c = getchar();
  while (!isdigit(c)) {
    if (c == '-') {
      f = -1;
    }
    c = getchar();
  }
  while (isdigit(c)) {
    r = 10 * r + c - '0';
    c = getchar();
  }
  return f * r;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
inline void writesp(long long x) { write(x), putchar(' '); }
inline void writeln(long long x) { write(x), puts(""); }
int main() {
  char str[10];
  N = read();
  for (register int i = 2; i <= N; ++i) {
    father[i] = read();
    add(father[i], i);
  }
  for (register int i = 1; i <= N; ++i) {
    arr[i] = read();
  }
  dfs1(1), dfs2(1, 1);
  build(1, N, 1);
  M = read();
  for (int i = 1; i <= M; ++i) {
    scanf("%s", str);
    if (str[0] == 'g') {
      int x = read();
      int ans = query(1, N, id[x], id[x] + size[x] - 1, 1);
      writeln(ans);
    } else {
      int x = read();
      update(1, N, id[x], id[x] + size[x] - 1, 1);
    }
  }
  return 0;
}