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;
using namespace chrono;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cout << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long int advceil(long long int num, long long int den) {
  return (num % den == 0 ? num / den : num / den + 1);
}
long long int lstbt(long long int val) {
  long long int msk = val & (val - 1);
  return log2(val ^ msk);
}
long long int modmul(long long int a, long long int b) {
  if (a < 1e9 and b < 1e9) return (a * b) % 1000000007;
  a %= 1000000007;
  b %= 1000000007;
  long long int res = 0;
  while (b > 0) {
    if (b & 1) res = (res + a) % 1000000007;
    a = (a * 2) % 1000000007;
    b /= 2;
  }
  return res;
}
long long int modexpo(long long int a, long long int b) {
  long long int res = 1;
  while (b > 0) {
    if (b & 1) res = modmul(res, a);
    a = modmul(a, a);
    b /= 2;
  }
  return res;
}
long long int gcd(long long int a, long long int b) {
  return a == 0 ? b : gcd(b % a, a);
}
vector<long long int> CALCfactor(long long int n) {
  vector<long long int> factor(n + 2, 0);
  for (long long int i = 4; i <= n; i += 2) factor[i] = 2;
  for (long long int j = 3; j <= n; j += 2) {
    if (factor[j]) continue;
    for (long long int i = 2 * j; i <= n; i += j) factor[i] = j;
  }
  return factor;
}
vector<long long int> CALCprimeNUM(long long int n) {
  vector<long long int> factor = CALCfactor(n);
  vector<long long int> primeNUM;
  primeNUM.reserve(n + 2);
  for (long long int i = 2; i <= n; i++)
    if (!factor[i]) primeNUM.push_back(i);
  return primeNUM;
}
vector<long long int> CALCprimeFACTOR(long long int n) {
  vector<long long int> factor = CALCfactor(n);
  vector<long long int> ans;
  while (factor[n] != 0) {
    ans.push_back(factor[n]);
    n /= factor[n];
  }
  if (n > 1) ans.push_back(n);
  return ans;
}
vector<long long int> unique(vector<long long int> x) {
  sort(x.begin(), x.end());
  set<long long int> s;
  vector<long long int> ans;
  ans.reserve(x.size());
  for (auto elem : x) s.insert(elem);
  for (auto elem : s) ans.push_back(elem);
  return ans;
}
pair<vector<long long int>, vector<long long int> > getFact(long long int n) {
  vector<long long int> fact(n + 1, 1), invfact(n + 1, 1);
  for (long long int i = 1; i <= n; i++)
    fact[i] = (i * (fact[i - 1])) % 1000000007;
  for (long long int i = 1; i <= n; i++)
    invfact[i] = (modexpo(i, 1000000007 - 2) * invfact[i - 1]) % 1000000007;
  return {fact, invfact};
}
void compress(vector<long long int>& arr, long long int n) {
  map<long long int, vector<long long int> > pos;
  for (long long int i = 1; i <= n; i++) pos[arr[i]].push_back(i);
  long long int cnt = 1;
  for (auto itr : pos) {
    for (auto elem : itr.second) arr[elem] = cnt;
    cnt++;
  }
}
bool rcomp(long long int a, long long int b) { return a > b; }
long long int one[4 * 200001] = {};
long long int two[4 * 200001] = {};
long long int lazy[4 * 200001] = {};
long long int arr[200001] = {};
void build(long long int s, long long int e, long long int idx) {
  if (s > e)
    return;
  else if (s == e) {
    one[idx] = arr[s];
    two[idx] = !arr[s];
    return;
  }
  long long int mid = (s + e) >> 1;
  build(s, mid, 2 * idx);
  build(mid + 1, e, 2 * idx + 1);
  one[idx] = one[2 * idx] + one[2 * idx + 1];
  two[idx] = two[2 * idx] + two[2 * idx + 1];
}
void call(long long int idx, long long int s, long long int e) {
  if (lazy[idx] & 1) swap(one[idx], two[idx]);
  if (s != e) lazy[2 * idx] += lazy[idx], lazy[2 * idx + 1] += lazy[idx];
  lazy[idx] = 0;
}
void update(long long int s, long long int e, long long int l, long long int r,
            long long int idx) {
  if (lazy[idx]) call(idx, s, e);
  if (e < l or r < s)
    return;
  else if (l <= s and e <= r) {
    lazy[idx]++;
    call(idx, s, e);
    return;
  }
  long long int mid = (s + e) >> 1;
  update(s, mid, l, r, 2 * idx);
  update(mid + 1, e, l, r, 2 * idx + 1);
  one[idx] = one[2 * idx] + one[2 * idx + 1];
  two[idx] = two[2 * idx] + two[2 * idx + 1];
}
pair<long long int, long long int> query(long long int s, long long int e,
                                         long long int l, long long int r,
                                         long long int idx) {
  if (lazy[idx]) call(idx, s, e);
  if (e < l or r < s)
    return {0, 0};
  else if (l <= s and e <= r) {
    return {one[idx], two[idx]};
  }
  long long int mid = (s + e) >> 1;
  pair<long long int, long long int> lt = query(s, mid, l, r, 2 * idx);
  pair<long long int, long long int> rt = query(mid + 1, e, l, r, 2 * idx + 1);
  return {lt.first + rt.first, lt.second + rt.second};
}
map<long long int, vector<long long int> > edges;
long long int tin[200001] = {};
long long int tout[200001] = {};
long long int temp[200001] = {};
long long int id = 0;
void dfs(long long int src, long long int par) {
  tin[src] = ++id;
  arr[tin[src]] = temp[src];
  for (auto itr : edges[src]) {
    if (itr == par) continue;
    dfs(itr, src);
  }
  tout[src] = id;
}
void solve() {
  long long int n;
  cin >> n;
  for (long long int i = 2; i <= n; i++) {
    long long int x;
    cin >> x;
    edges[i].push_back(x);
    edges[x].push_back(i);
  }
  for (long long int i = 1; i <= n; i++) cin >> temp[i];
  dfs(1, 0);
  build(1, n, 1);
  long long int q;
  cin >> q;
  while (q--) {
    string typ;
    cin >> typ;
    if (typ == "pow") {
      long long int x;
      cin >> x;
      update(1, n, tin[x], tout[x], 1);
    } else {
      long long int x;
      cin >> x;
      cout << query(1, n, tin[x], tout[x], 1).first << "\n";
    }
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  auto start1 = high_resolution_clock::now();
  solve();
  auto stop1 = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop1 - start1);
}