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;
template <class T>
struct SegmentTree {
  inline int m(int left, int right) { return (left + right) >> 1; }
  inline int l(int current) { return 2 * current + 1; }
  inline int r(int current) { return 2 * current + 2; }
  SegmentTree() {}
  SegmentTree(int size)
      : size(size), value(4 * size, 0), delta(4 * size, getNeutralDelta()) {
    init(0, 0, size - 1);
  }
  void init(int root, int left, int right) {
    if (left == right) {
      value[root] = 0;
      delta[root] = getNeutralDelta();
    } else {
      int mid = m(left, right);
      init(l(root), left, mid);
      init(r(root), mid + 1, right);
      value[root] = queryOperation(value[l(root)], value[r(root)]);
      delta[root] = getNeutralDelta();
    }
  }
  void modify(int from, int to, T delta) {
    modify(from, to, delta, 0, 0, size - 1);
  }
  void modify(int from, int to, T delta, int root, int left, int right) {
    if (from == left && to == right) {
      this->delta[root] = joinDeltas(this->delta[root], delta);
      return;
    }
    pushDelta(root, left, right);
    int mid = m(left, right);
    if (from <= mid) modify(from, min(to, mid), delta, l(root), left, mid);
    if (to > mid)
      modify(max(from, mid + 1), to, delta, r(root), mid + 1, right);
    value[root] = queryOperation(
        joinValueWithDelta(
            value[l(root)],
            deltaEffectOnSegment(this->delta[l(root)], mid - left + 1)),
        joinValueWithDelta(
            value[r(root)],
            deltaEffectOnSegment(this->delta[r(root)], right - mid)));
  }
  T query(int from, int to) { return query(from, to, 0, 0, size - 1); }
  T query(int from, int to, int root, int left, int right) {
    if (from == left && to == right)
      return joinValueWithDelta(
          value[root], deltaEffectOnSegment(delta[root], right - left + 1));
    pushDelta(root, left, right);
    int mid = m(left, right);
    if (from <= mid && to > mid)
      return queryOperation(
          query(from, min(to, mid), l(root), left, mid),
          query(max(from, mid + 1), to, r(root), mid + 1, right));
    else if (from <= mid)
      return query(from, min(to, mid), l(root), left, mid);
    else if (to > mid)
      return query(max(from, mid + 1), to, r(root), mid + 1, right);
  }
  T joinValueWithDelta(T value, T delta) {
    if (delta == getNeutralDelta()) return value;
    return modifyOperation(value, delta);
  }
  T joinDeltas(T delta1, T delta2) {
    if (delta1 == getNeutralDelta()) return delta2;
    if (delta2 == getNeutralDelta()) return delta1;
    return modifyOperation(delta1, delta2);
  }
  void pushDelta(int root, int left, int right) {
    value[root] = joinValueWithDelta(
        value[root], deltaEffectOnSegment(delta[root], right - left + 1));
    delta[l(root)] = joinDeltas(delta[l(root)], delta[root]);
    delta[r(root)] = joinDeltas(delta[r(root)], delta[root]);
    delta[root] = getNeutralDelta();
  }
  int size;
  vector<T> value;
  vector<T> delta;
  T modifyOperation(T old, T change) { return change - old; }
  T queryOperation(T leftValue, T rightValue) { return leftValue + rightValue; }
  T deltaEffectOnSegment(T delta, int segmentLength) {
    if (delta == 0) return 0;
    return segmentLength;
  }
  T getNeutralDelta() { return 0; }
};
vector<int> tree[200001];
int nomor[200001];
int until[200001];
int p = 0;
void dfs(int cur, int par) {
  nomor[cur] = p++;
  for (int i = 0; i < tree[cur].size(); i++) {
    if (tree[cur][i] != par) {
      dfs(tree[cur][i], cur);
    }
  }
  until[cur] = (p - 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int a;
    cin >> a;
    a--;
    tree[a].push_back(i);
  }
  dfs(0, -1);
  SegmentTree<int> sg(n);
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a == 1) sg.modify(nomor[i], nomor[i], a);
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    string s;
    int p;
    cin >> s >> p;
    p--;
    if (s == "get") {
      cout << sg.query(nomor[p], until[p]) << endl;
    } else {
      sg.modify(nomor[p], until[p], 1);
    }
  }
}