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.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.FileInputStream;
import java.util.ArrayList;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

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

    static class EDanilAndAPartTimeJob {
        private int n;
        private int[] arr;
        private int[] segmentArr;
        private int timer = 0;
        private int ind = 0;
        private int[] tin;
        private int[] tout;
        private int[] indexMap;
        private int[] subtreeSize;
        private ArrayList<Integer>[] graph;

        private void dfs(int v, int p) {
            tin[v] = timer++;
            indexMap[v] = ind++;
            for (int to : graph[v]) if (to != p) dfs(to, v);
            tout[v] = timer++;
        }

        public void solve(int testNumber, InputReader in, OutputWriter out) {
            n = in.nextInt();
            tin = new int[n + 1];
            tout = new int[n + 1];
            subtreeSize = new int[n + 1];
            arr = new int[n + 1];
            segmentArr = new int[n];
            indexMap = new int[n + 1];
            graph = new ArrayList[n + 1];
            for (int i = 0; i <= n; i++) graph[i] = new ArrayList<>();
            for (int i = 2; i <= n; i++) {
                int parent = in.nextInt();
                graph[parent].add(i);
            }
            dfs(1, 1);
            for (int i = 1; i <= n; i++) {
                arr[i] = in.nextInt();
                int ind = indexMap[i];
                if (arr[i] == 1) segmentArr[ind] = 1;
            }
            for (int i = 1; i <= n; i++) subtreeSize[i] = 1 + (tout[i] - tin[i] - 1) / 2;
            SegmentTree st = new SegmentTree();
            int q = in.nextInt();
            while (q-- > 0) {
                String type = in.next();
                int x = in.nextInt();
                int qs = indexMap[x], qe = qs - 1 + subtreeSize[x];
                if (type.equals("get")) out.println(st.querySum(0, 0, n - 1, qs, qe));
                else st.rangeUpdate(0, 0, n - 1, qs, qe);
            }
            out.flush();
        }

        class SegmentTree {
            private int[] st;
            private int[] lazy;

            private SegmentTree() {
                int x = (int) Math.ceil(Util.log2(n));
                st = new int[(1 << (x + 1)) - 1];
                lazy = new int[(1 << (x + 1)) - 1];
                buildTree(0, 0, n - 1);
            }

            private void buildTree(int sti, int sts, int ste) {
                if (sts == ste) {
                    st[sti] = segmentArr[sts];
                    return;
                }
                int mid = Util.getMid(sts, ste);
                buildTree((sti << 1) | 1, sts, mid);
                buildTree((sti + 1) << 1, mid + 1, ste);
                st[sti] = st[(sti << 1) | 1] + st[(sti + 1) << 1];
            }

            private int querySum(int sti, int sts, int ste, int qs, int qe) {
                if (sts > qe || ste < qs) return 0;
                propagate(sti, sts, ste);
                if (qs <= sts && ste <= qe) return st[sti];
                int mid = Util.getMid(sts, ste);
                return querySum((sti << 1) | 1, sts, mid, qs, qe) + querySum((sti + 1) << 1, mid + 1, ste, qs, qe);
            }

            private void propagate(int sti, int sts, int ste) {
                if (lazy[sti] != 0) {
                    st[sti] = (ste - sts + 1) - st[sti];
                    if (sts != ste) {
                        lazy[(sti << 1) | 1] ^= 1;
                        lazy[(sti + 1) << 1] ^= 1;
                    }
                    lazy[sti] = 0;
                }
            }

            private void rangeUpdate(int sti, int sts, int ste, int qs, int qe) {
                if (sts > qe || ste < qs) return;
                if ((qs <= sts && ste <= qe) && (lazy[sti] == 1)) {
                    lazy[sti] = 0;
                    return;
                }
                if (qs <= sts && ste <= qe) {
                    lazy[sti] = 1;
                    return;
                }
                propagate(sti, sts, ste);
                int mid = Util.getMid(sts, ste);
                rangeUpdate((sti << 1) | 1, sts, mid, qs, qe);
                rangeUpdate((sti + 1) << 1, mid + 1, ste, qs, qe);
                if (sts != ste) {
                    propagate((sti << 1) | 1, sts, mid);
                    propagate((sti + 1) << 1, mid + 1, ste);
                    st[sti] = st[(sti << 1) | 1] + st[(sti + 1) << 1];
                }
            }

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;
        private ArrayList<String> res = new ArrayList<>();
        private StringBuilder sb = new StringBuilder("");

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void println(Object... objects) {
            for (int i = 0; i < objects.length; i++) {
                sb.append(objects[i]);
            }
            res.add(sb.toString());
            sb = new StringBuilder("");
        }

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

        public void flush() {
            for (String str : res) writer.printf("%s\n", str);
            res.clear();
            sb = new StringBuilder("");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public InputReader(FileInputStream file) {
            this.stream = file;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res = (res << 3) + (res << 1) + c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }

    static class Util {
        public static int getMid(int a, int b) {
            return (a + b) >> 1;
        }

        public static double log2(int num) {
            return Math.log(num) / Math.log(2);
        }

    }
}