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

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

    static class andfs {
        int[] pos = new int[1000000];
        int ctr;
        int[] tree;
        int[] lazy;
        int[] act;
        int[] ar;
        ArrayList<ArrayList<Integer>> list;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            list = in.initlist(n + 1);
            for (int i = 2; i <= n; i++) {
                int val = in.nextInt();
                list.get(val).add(i);
            }
            ar = in.nextIntArray(n);
            dfs(1, 0);
            int start[] = in.initdp(n + 1);
            int end[] = in.initdp(n + 1);
            for (int i = 0; i <= ctr; i++) {
                if (start[pos[i]] == -1)
                    start[pos[i]] = i;
            }
            for (int i = ctr; i >= 0; i--) {
                if (end[pos[i]] == -1)
                    end[pos[i]] = i;
            }
            act = new int[(ctr + 1) / 2];
            int po = 0;
            for (int i = 0; i <= ctr; i++) {
                if (end[pos[i]] == i) {
                    end[pos[i]] = po - 1;
                    continue;
                }
                start[pos[i]] = po;
                act[po++] = pos[i];
            }
            tree = new int[act.length * 4];
            lazy = new int[act.length * 4];
            build(1, 0, act.length - 1);
            int q = in.nextInt();
            while (q > 0) {
                String str = in.readString();
                if (str.equals("get")) {
                    int val = in.nextInt();
                    out.println(queryRange(1, 0, act.length - 1, start[val], end[val]));
                } else {
                    int val = in.nextInt();
                    updateRange(1, 0, act.length - 1, start[val], end[val], 1);
                }


                q--;
            }
        }

        void dfs(int node, int parent) {
            pos[ctr] = node;
            for (int i = 0; i < list.get(node).size(); i++) {
                int x = list.get(node).get(i);
                if (x != parent) {
                    ctr++;
                    dfs(x, node);

                }
            }
            pos[++ctr] = node;
        }

        void build(int node, int start, int end) {
            if (start == end) {
                // Leaf node will have a single element
                //System.out.println(start+" "+node+" "+tree.length+" "+ar.length+" "+act.length );
                tree[node] = ar[act[start] - 1];
            } else {
                int mid = (start + end) / 2;
                // Recurse on the left child
                build(2 * node, start, mid);
                // Recurse on the right child
                build(2 * node + 1, mid + 1, end);
                // Internal node will have the sum of both of its children
                tree[node] = tree[2 * node] + tree[2 * node + 1];
            }
        }

        void updateRange(int node, int start, int end, int l, int r, int val) {
            if (lazy[node] != 0) {
                // This node needs to be updated
                tree[node] = (end - start + 1) - tree[node];    // Update it
                if (start != end) {
                    lazy[node * 2] = (lazy[node * 2] + 1) % 2;
                    lazy[node * 2 + 1] = (lazy[node * 2 + 1] + 1) % 2;             // Mark child as lazy
                }
                lazy[node] = 0;                                  // Reset it
            }
            if (start > end || start > r || end < l)              // Current segment is not within range [l, r]
                return;
            if (start >= l && end <= r) {
                // Segment is fully within range
                tree[node] = (end - start + 1) - tree[node];
                if (start != end) {
                    lazy[node * 2] = (lazy[node * 2] + 1) % 2;
                    lazy[node * 2 + 1] = (lazy[node * 2 + 1] + 1) % 2;
                }
                return;
            }
            int mid = (start + end) / 2;
            updateRange(node * 2, start, mid, l, r, val);        // Updating left child
            updateRange(node * 2 + 1, mid + 1, end, l, r, val);   // Updating right child
            tree[node] = tree[node * 2] + tree[node * 2 + 1];        // Updating root with max value
        }

        int queryRange(int node, int start, int end, int l, int r) {
            if (start > end || start > r || end < l)
                return 0;         // Out of range
            if (lazy[node] != 0) {
                // This node needs to be updated
                tree[node] = (end - start + 1) - tree[node];          // Update it
                if (start != end) {
                    lazy[node * 2] = (lazy[node * 2] + 1) % 2;
                    lazy[node * 2 + 1] = (lazy[node * 2 + 1] + 1) % 2;    // Mark child as lazy
                }
                lazy[node] = 0;                 // Reset it
            }
            if (start >= l && end <= r)             // Current segment is totally within range [l, r]
                return tree[node];
            int mid = (start + end) / 2;
            int p1 = queryRange(node * 2, start, mid, l, r);         // Query left child
            int p2 = queryRange(node * 2 + 1, mid + 1, end, l, r); // Query right child
            return (p1 + p2);
        }

    }

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

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

        public int read() {
            //*-*------clare------

            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 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 {
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public int[] nextIntArray(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = nextInt();
            }
            return a;
        }

        public ArrayList<ArrayList<Integer>> initlist(int n) {
            ArrayList<ArrayList<Integer>> list = new ArrayList<>();
            for (int i = 0; i <= n; i++) {
                list.add(new ArrayList<Integer>());
            }
            return list;
        }

        public int[] initdp(int n) {
            int ar[] = new int[n];
            for (int i = 0; i < n; i++) {
                ar[i] = -1;
            }
            return ar;
        }

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

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

    }
}

