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 inf = (int)1e9 + 7;
int up(int n) {
  int r = 1;
  while (r < n) r <<= 1;
  return r;
}
class segtree {
  vector<int> arr;
  vector<bool> laz;
  void inv(int l, int r, int cl, int cr, int v) {
    if (r <= cl || cr <= l) return;
    push(v);
    if (l <= cl && cr <= r) {
      laz[v] = !laz[v];
      return;
    }
    int ct = (cl + cr) / 2;
    inv(l, r, cl, ct, 2 * v);
    inv(l, r, ct, cr, 2 * v + 1);
    upd(v);
  }
  int cnt(int l, int r, int cl, int cr, int v) {
    if (r <= cl || cr <= l) return 0;
    push(v);
    if (l <= cl && cr <= r) return arr[v];
    int ct = (cl + cr) / 2;
    ct = cnt(l, r, cl, ct, 2 * v) + cnt(l, r, ct, cr, 2 * v + 1);
    upd(v);
    return ct;
  }
  void push(int v) {
    if (laz[v]) {
      laz[v] = false;
      arr[v] = arr.size() / up(v + 1) - arr[v];
      if (v < (int)arr.size() / 2) {
        laz[2 * v] = !laz[2 * v];
        laz[2 * v + 1] = !laz[2 * v + 1];
      }
    }
  }
  void upd(int v) {
    if (v < (int)arr.size() / 2) {
      push(2 * v);
      push(2 * v + 1);
      arr[v] = arr[2 * v] + arr[2 * v + 1];
    }
  }

 public:
  segtree(int n) : arr(2 * up(n)), laz(2 * up(n)) {}
  void inv(int l, int r) { inv(l, r, 0, arr.size() / 2, 1); }
  int cnt(int l, int r) { return cnt(l, r, 0, arr.size() / 2, 1); }
};
void dfs(const vector<vector<int>> &gr, int v, vector<int> &in,
         vector<int> &out, int &cnt) {
  in[v] = cnt++;
  for (auto it : gr[v]) dfs(gr, it, in, out, cnt);
  out[v] = ++cnt;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  vector<vector<int>> gr(n);
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    p--;
    gr[p].push_back(i);
  }
  vector<int> in(n), out(n);
  n = 0;
  dfs(gr, 0, in, out, n);
  segtree st(n);
  n /= 2;
  for (int i = 0; i < n; i++) {
    int t;
    cin >> t;
    if (t == 1) {
      st.inv(in[i], in[i] + 1);
      st.inv(out[i] - 1, out[i]);
    }
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    string s;
    int t;
    cin >> s >> t;
    t--;
    if (s == "get") {
      cout << st.cnt(in[t], out[t]) / 2 << endl;
    } else {
      assert(s == "pow");
      st.inv(in[t], out[t]);
    }
  }
  return 0;
}