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 JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class DanilPartimeJob {
    
    int N = (int) 2e5 + 10;
    
    int n;
    int[] par;
    int[] t;
    int[][] G;
    
    int nxt = 0;
    int[] seq = new int[N];
    int[] nl = new int[N], nr = new int[N];
    
    int h;
    int[] tree; 
    int[] lazy; 
    
    void solve() {
        n = in.nextInt();
        par = new int[n];
        for (int i = 0; i < n - 1; i++) {
            par[i + 1] = in.nextInt() - 1;
        }
        t = new int[n];
        for (int i = 0; i < n; i++) t[i] = in.nextInt();
        
        int[] fr = new int[n - 1], to = new int[n - 1];
        for (int i = 0; i < n - 1; i++) {
            fr[i] = par[i + 1];
            to[i] = i + 1;
        }
        G = build_graph(n, fr, to);
        
        dfs(0, -1);
        
        h = 32 - Integer.numberOfLeadingZeros(n);
        tree = new int[n << 1];
        lazy = new int[n];
        for (int i = 0; i < n; i++) {
            tree[n + i] = t[seq[i]];
        }
        for (int i = n - 1; i > 0; i--) {
            tree[i] = tree[i << 1] + tree[i << 1 | 1];
        }
        
        int Q = in.nextInt();
        while (Q-- > 0) {
            String type = in.nextToken();
            int u = in.nextInt() - 1;
            if ("get".equals(type)) {
                int ans = query(nl[u], nr[u]);
                out.println(ans);
            } else {
                update(nl[u], nr[u]);
            }
        }
    }
    
    int query(int l, int r) {
        push(l + n);
        push(r + n - 1);
        int sum = 0;
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if ((l & 1) > 0) sum += tree[l++];
            if ((r & 1) > 0) sum += tree[--r];
        }
        return sum;
    }
    
    void update(int l, int r) {
        int l0 = l + n, r0 = r + n;
        int k = 1;
        for (l += n, r += n; l < r; l >>= 1, r >>= 1, k <<= 1) {
            if ((l & 1) > 0) apply(l++, k);
            if ((r & 1) > 0) apply(--r, k);
        }
        raise(l0);
        raise(r0 - 1);
    }
    
    void raise(int i) {
        int k = 2;
        for (int p = i >> 1; p > 0; p >>= 1, k <<= 1) {
            if (lazy[p] == 0) tree[p] = tree[p << 1] + tree[p << 1 | 1];
            else tree[p] = k - (tree[p << 1] + tree[p << 1 | 1]);
        }
    }
    
    void push(int i) {
        for (int s = h; s > 0; s--) {
            int p = i >> s;
            if (lazy[p] == 1) {
                apply(p << 1, 1 << (s - 1));
                apply(p << 1 | 1, 1 << (s - 1));
                lazy[p] = 0;
            }
        }
    }
    
    void apply(int i, int k) {
        tree[i] = k - tree[i];
        if (i < n) lazy[i] ^= 1;
    }
    
    void dfs(int u, int p) {
        seq[nxt] = u;
        nl[u] = nxt++;
        for (int v : G[u]) {
            if (v != p) {
                dfs(v, u);
            }
        }
        nr[u] = nxt;
    }
    
    int[][] build_graph(int n, int[] from, int[] to) {
        int[][] G = new int[n][];
        int[] cnt = new int[n];
        for (int i = 0; i < from.length; i++) {
            cnt[from[i]]++;
            cnt[to[i]]++;
        }
        for (int i = 0; i < n; i++) G[i] = new int[cnt[i]];
        for (int i = 0; i < from.length; i++) {
            G[from[i]][--cnt[from[i]]] = to[i];
            G[to[i]][--cnt[to[i]]] = from[i];
        }
        return G;
    }
    
    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new DanilPartimeJob().solve();
        out.close();
    }
    
    static FastScanner in;
    static PrintWriter out;
    
    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;
        
        public FastScanner(BufferedReader in) {
            this.in = in;
        }
        
        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        public int nextInt() {
            return Integer.parseInt(nextToken());
        }
        
        public long nextLong() {
            return Long.parseLong(nextToken());
        }
        
        public double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }
}