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:
/*
Solution: Label the nodes in DFS order to make each subtree cover a contiguous range in a segment tree. Then, just
handle the queries using the segment tree. Lazily propagate the light switches; get query is just sum of a range.

Runtime: O((N + Q) * log(N))
*/

import java.util.*;
import java.io.*;

@SuppressWarnings("unchecked")
public class daniljob {
    int N, currID;
    int[] parent, startLabel, endLabel;
    boolean[] initLights;
    ArrayList<Integer>[] children;

    daniljob() throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        StringTokenizer st = new StringTokenizer(in.readLine());
        N = Integer.parseInt(st.nextToken());
        children = new ArrayList[N];
        for (int i = 0; i < N; i++) children[i] = new ArrayList<>(2);
        st = new StringTokenizer(in.readLine());
        parent = new int[N];
        for (int i = 1; i < N; i++) {
            parent[i] = Integer.parseInt(st.nextToken()) - 1;
            children[parent[i]].add(i);
        }

        // Label nodes in DFS order
        startLabel = new int[N];
        endLabel = new int[N];
        currID = 0;
        labelDFS(0);

        initLights = new boolean[N];
        st = new StringTokenizer(in.readLine());
        for (int i = 0; i < N; i++) initLights[startLabel[i]] = st.nextToken().equals("1");

        // Handle queries online
        SegmentTree seg = new SegmentTree(N, initLights);
        int Q = Integer.parseInt(in.readLine());
        String type;
        int n;
        for (int i = 0; i < Q; i++) {
            st = new StringTokenizer(in.readLine());
            type = st.nextToken();
            n = Integer.parseInt(st.nextToken()) - 1;
            if (type.equals("pow")) {
                seg.flipLights(startLabel[n], endLabel[n]);
            } else {
                out.println(seg.query(startLabel[n], endLabel[n]));
            }
        }
        in.close();
        out.close();
    }

    void labelDFS(int n) {
        // Start label is also the node's actual label
        startLabel[n] = currID++;
        for (int c : children[n]) labelDFS(c);
        endLabel[n] = currID - 1;
    }

    public static void main(String[] args) throws IOException {
        new daniljob();
    }

    // All lights initally off
    static class SegmentTree {
        int size;
        int[] vals;
        boolean[] lazy;

        SegmentTree(int size, boolean[] initial) {
            this.size = size;
            vals = new int[size * 4 + 1];
            lazy = new boolean[size * 4 + 1];
            initTree(1, 0, size - 1, initial);
        }

        void initTree(int n, int lb, int ub, boolean[] initial) {
            if (lb == ub) {
                vals[n] = initial[lb] ? 1 : 0;
            } else {
                initTree(n * 2, lb, (lb + ub) / 2, initial);
                initTree(n * 2 + 1, (lb + ub) / 2 + 1, ub, initial);
                vals[n] = vals[n*2] + vals[n*2+1];
            }
        }

        void flipLights(int l, int r) {
            flipLights(1, 0, size - 1, l, r);
        }

        void flipLights(int n, int lb, int ub, int l, int r) {
            if (lb > r || ub < l) return;
            else if (lb >= l && ub <= r) {
                lazy[n] = !lazy[n];
                vals[n] = calcVal(n, lb, ub);
                return;
            }

            propagate(n, lb, ub);
            flipLights(n*2, lb, (lb+ub)/2, l, r);
            flipLights(n*2+1, (lb+ub)/2+1, ub, l, r);
            vals[n] = vals[n*2] + vals[n*2+1];
        }

        int query(int l, int r) {
            return query(1, 0, size - 1, l, r);
        }

        int query(int n, int lb, int ub, int l, int r) {
            if (lb > r || ub < l) return 0;
            else if (lb >= l && ub <= r) return vals[n];

            propagate(n, lb, ub);
            return query(n*2, lb, (lb+ub)/2, l, r) + query(n*2+1, (lb+ub)/2+1, ub, l, r);
        }

        // Flips lights
        int calcVal(int n, int lb, int ub) {
            return (ub - lb + 1) - vals[n];
        }

        void propagate(int n, int lb, int ub) {
            if (lazy[n]) {
                lazy[n] = false;
                vals[n*2] = calcVal(n*2, lb, (lb+ub)/2);
                lazy[n*2] = !lazy[n*2];
                vals[n*2+1] = calcVal(n*2+1, (lb+ub)/2+1, ub);
                lazy[n*2+1] = !lazy[n*2+1];
            }
        }
    }
}