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;
void setIO(const string &name = "") {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  if (name.length()) {
    freopen((name + ".in").c_str(), "r", stdin);
    freopen((name + ".out").c_str(), "w", stdout);
  }
}
template <typename T>
void read(vector<T> &a) {
  for (auto &x : a) cin >> x;
}
template <typename T>
void read(vector<T> &a, int n) {
  a.resize(n);
  for (auto &x : a) cin >> x;
}
template <class T, class U>
ostream &operator<<(ostream &out, const pair<T, U> &v) {
  out << "(";
  out << v.first << "," << v.second;
  return out << ")";
}
template <class T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << "[";
  for (auto(i) = 0; (i) < ((int)(v).size()); (i)++) {
    if (i) out << ", ";
    out << v[i];
  }
  return out << "]";
}
template <typename T>
void print(vector<T> &a) {
  for (const auto &x : a) cout << x << ' ';
  cout << '\n';
}
void MOD(int &x, int m = 1000000007) {
  x %= m;
  if (x < 0) x += m;
}
template <typename T>
void dbg(const char *name, T &&arg1) {
  cout << name << " : " << arg1 << '\n';
}
template <typename T, typename... U>
void dbg(const char *names, T &&arg1, U &&...args) {
  const char *comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  dbg(comma + 1, args...);
}
template <class T>
void read(T &x) {
  cin >> x;
}
template <class T, class... U>
void read(T &t, U &...u) {
  read(t);
  read(u...);
}
int gcd(int a, int b) { return !a ? b : gcd(b % a, a); }
struct SegTree {
  int size = 1;
  vector<int> elements, a;
  vector<bool> lazy;
  void init(int n) {
    while (size < n) size *= 2;
    elements.assign(2 * size, 0);
    lazy.assign(2 * size, false);
  }
  void push(int x, int lx, int rx) {
    if (!lazy[x]) return;
    lazy[x] = false;
    lazy[2 * x + 1] = !lazy[2 * x + 1];
    lazy[2 * x + 2] = !lazy[2 * x + 2];
    int mid = (lx + rx) / 2;
    elements[2 * x + 1] = (mid - lx) - elements[2 * x + 1];
    elements[2 * x + 2] = (rx - mid) - elements[2 * x + 2];
  }
  void pull(int x) { elements[x] = elements[2 * x + 1] + elements[2 * x + 2]; }
  void build(int x, int lx, int rx) {
    if (rx - lx == 1) {
      if (lx < (int)(a).size()) {
        elements[x] = a[lx];
      }
      return;
    }
    int mid = (lx + rx) / 2;
    build(2 * x + 1, lx, mid);
    build(2 * x + 2, mid, rx);
    pull(x);
  }
  void build(vector<int> &x) {
    a = x;
    build(0, 0, size);
  }
  void flip(int l, int r, int x, int lx, int rx) {
    if (l >= rx or r <= lx) return;
    if (l <= lx and rx <= r) {
      lazy[x] = !lazy[x];
      elements[x] = (rx - lx) - elements[x];
      return;
    }
    push(x, lx, rx);
    int mid = (lx + rx) / 2;
    flip(l, r, 2 * x + 1, lx, mid);
    flip(l, r, 2 * x + 2, mid, rx);
    pull(x);
  }
  void flip(int l, int r) { flip(l, r, 0, 0, size); }
  int get(int l, int r, int x, int lx, int rx) {
    if (l >= rx or r <= lx) return 0;
    if (l <= lx and rx <= r) {
      return elements[x];
    }
    push(x, lx, rx);
    int mid = (lx + rx) / 2;
    int res = get(l, r, 2 * x + 1, lx, mid);
    res += get(l, r, 2 * x + 2, mid, rx);
    return res;
  }
  int get(int l, int r) { return get(l, r, 0, 0, size); }
};
int n, q;
vector<int> adj[int(2e5 + 10)], p;
vector<int> tin, tout, ar, st_ar;
int tt = -1;
void dfs(int x, int par = -1) {
  tt++;
  ar.emplace_back(x);
  tin[x] = tt;
  for (auto &(c) : (adj[x])) {
    if (c == par) continue;
    dfs(c, x);
  }
  tout[x] = tt;
}
void euler_tour() {
  tin.resize(n);
  tout.resize(n);
  ar.reserve(n);
  dfs(0);
  st_ar.resize(n);
  for (auto(i) = 0; (i) < (n); (i)++) {
    st_ar[i] = p[ar[i]];
  }
}
int32_t main() {
  setIO();
  read(n);
  int x;
  for (auto(i) = 1; (i) < (n); (i)++) {
    cin >> x;
    x--;
    adj[x].emplace_back(i);
    adj[i].emplace_back(x);
  }
  read(p, n);
  euler_tour();
  SegTree st;
  st.init(n);
  st.build(st_ar);
  cin >> q;
  string op;
  int v;
  while (q--) {
    read(op, v);
    v--;
    if (op == "get") {
      cout << st.get(tin[v], tout[v] + 1) << '\n';
    } else {
      st.flip(tin[v], tout[v] + 1);
    }
  }
  return 0;
}