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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.Reader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author jgrdlgrd
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ExtendedReader in = new ExtendedReader(inputStream);
        ExtendedWriter out = new ExtendedWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        List<Integer>[] graph;
        int[] on;
        TaskE.Node[] nodes;
        int[] start;
        int[] end;

        int dfs(int v, int index) {
            start[v] = index;
            nodes[index] = new TaskE.Node(on[v], 1 - on[v]);

            for (int to : graph[v]) {
                index = dfs(to, index + 1);
            }

            end[v] = index;

            return index;
        }

        public void solve(int testNumber, ExtendedReader in, ExtendedWriter out) {
            int n = in.readInt();

            graph = new List[n];
            for (int i = 0; i < n; i++) {
                graph[i] = new ArrayList<>();
            }

            for (int i = 1; i < n; i++) {
                graph[in.readInt() - 1].add(i);
            }

            on = in.readIntArray(n);
            nodes = new TaskE.Node[n];
            start = new int[n];
            end = new int[n];
            dfs(0, 0);

            int q = in.readInt();
            TaskE.Node updater = new TaskE.Node(0, 0);
            updater.flag = true;

            SegmentTree<TaskE.Node> st = new SegmentTree<>(nodes, updater);

            for (int i = 0; i < q; i++) {
                String action = in.next();
                int v = in.readInt() - 1;

                if (action.equals("pow")) st.update(start[v], end[v], updater);
                else out.println(st.query(start[v], end[v]).onSum);
            }
        }

        static class Node extends SegTreeNode<TaskE.Node> {
            int onSum = 0;
            int offSum = 0;
            boolean flag = false;

            Node(int on, int off) {
                onSum = on;
                offSum = off;
            }


            public TaskE.Node newInstance() {
                return new TaskE.Node(0, 0);
            }


            public TaskE.Node[] newArray(int size) {
                return new TaskE.Node[size];
            }


            public void pull(TaskE.Node ch1, TaskE.Node ch2) {
                onSum = ch1.onSum + ch2.onSum;
                offSum = ch1.offSum + ch2.offSum;
            }


            public void clear() {
                flag = false;
            }


            public void update(TaskE.Node info) {
                if (info.flag) {
                    int tmp = onSum;
                    onSum = offSum;
                    offSum = tmp;

                    flag = !flag;
                }
            }

        }

    }

    static class ExtendedWriter extends PrintWriter {
        public ExtendedWriter(Writer writer) {
            super(writer);
        }

        public ExtendedWriter(OutputStream stream) {
            super(stream);
        }

        public void close() {
            super.close();
        }

    }

    static class ExtendedReader extends BufferedReader {
        private StringTokenizer tokenizer;

        public ExtendedReader(Reader reader) {
            super(reader);
        }

        public ExtendedReader(InputStream stream) {
            super(new InputStreamReader(stream));
        }

        public String readString() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public String next() {
            return readString();
        }

        public int readInt() {
            return Integer.parseInt(readString());
        }

        public int[] readIntArray(int n) {
            int[] array = new int[n];
            for (int i = 0; i < n; i++) {
                array[i] = readInt();
            }
            return array;
        }

    }

    static abstract class SegTreeNode<T extends SegTreeNode<T>> {
        public abstract T newInstance();

        public abstract T[] newArray(int size);

        public abstract void update(T info);

        public abstract void pull(T ch1, T ch2);

        public abstract void clear();

        void push(T ch1, T ch2) {
            ch1.update((T) this);
            ch2.update((T) this);
            clear();
        }

        T merge(T ch1, T ch2) {
            T node = newInstance();
            node.pull(ch1, ch2);
            return node;
        }

    }

    static class SegmentTree<T extends SegTreeNode<T>> {
        private int n;
        private T[] tree;
        private T N;

        public SegmentTree(T[] arr, T N) {
            this.N = N;
            n = arr.length;
            tree = N.newArray(n * 4);

            build(arr, 1, 0, n - 1);
        }

        private void push(int v) {
            tree[v].push(tree[2 * v], tree[2 * v + 1]);
        }

        private void pull(int v) {
            tree[v].pull(tree[2 * v], tree[2 * v + 1]);
        }

        private void build(T[] arr, int v, int tl, int tr) {
            if (tl == tr) {
                tree[v] = arr[tl];
                return;
            }

            int tm = (tl + tr) / 2;
            build(arr, 2 * v, tl, tm);
            build(arr, 2 * v + 1, tm + 1, tr);
            tree[v] = N.merge(tree[2 * v], tree[2 * v + 1]);
        }

        public T query(int l, int r) {
            return query(1, 0, n - 1, l, r);
        }

        private T query(int v, int tl, int tr, int l, int r) {
            if (l > r) return N;
            if (tl == l && tr == r) return tree[v];

            int tm = (tl + tr) / 2;
            push(v);
            return N.merge(
                    query(v * 2, tl, tm, l, Math.min(r, tm)),
                    query(2 * v + 1, tm + 1, tr, Math.max(tm + 1, l), r)
            );
        }

        public void update(int l, int r, T info) {
            update(1, 0, n - 1, l, r, info);
        }

        private void update(int v, int tl, int tr, int l, int r, T info) {
            if (l > r) return;
            if (tl == l && tr == r) tree[v].update(info);
            else {
                int tm = (tl + tr) / 2;
                push(v);
                update(v * 2, tl, tm, l, Math.min(r, tm), info);
                update(2 * v + 1, tm + 1, tr, Math.max(tm + 1, l), r, info);
                pull(v);
            }
        }

    }
}