#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;   }