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

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

    static class TaskE {
        static int[] seg;
        static int[] lazy;
        static int N;
        static int size;
        static int[] lights;

        public void solve(int testNumber, FastReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] pars = new int[n];
            pars[0] = -1;
            for (int i = 1; i < n; ++i) {
                pars[i] = in.nextInt() - 1;
            }
            int[][] g = GraphUtils.parentToG(pars);
            EulerTour eulerTour = new EulerTour(g);
            int[] begin = eulerTour.getBegin(), end = eulerTour.getEnd();
            lights = new int[n + 1];
            for (int i = 0; i < n; ++i) {
                lights[begin[i]] = in.nextInt();
            }
            N = lights.length;
            size = N << 2;
            seg = new int[size];
            lazy = new int[size];
            build(0, N - 1, 0);
            int Q = in.nextInt();
            for (int q = 0; q < Q; ++q) {
                String qq = in.nextString();
                int ind = in.nextInt() - 1;
                if (qq.equals("get")) {
                    out.println(getSum(begin[ind], end[ind]));
                } else {
                    update(begin[ind], end[ind]);
                }
            }
        }

        private static void build(int s, int e, int c) {
            if (s == e) {
                seg[c] = lights[s];
                return;
            }
            int m = (s + e) >>> 1;
            build(s, m, 2 * c + 1);
            build(m + 1, e, 2 * c + 2);
            seg[c] = seg[2 * c + 1] + seg[2 * c + 2];
        }

        public static void update(int l, int r) {
            update(0, N - 1, 0, l, r);
        }

        public static void update(int s, int e, int c, int l, int r) {
            if (lazy[c] != 0) {
                lazy[c] = 0;
                if (s != e) {
                    lazy[2 * c + 1] ^= 1;
                    lazy[2 * c + 2] ^= 1;
                }
                seg[c] = e - s + 1 - seg[c];
            }
            if (l > r || s > e || l > e || r < s) return;
            if (s >= l && e <= r) {
                if (s != e) {
                    lazy[2 * c + 1] ^= 1;
                    lazy[2 * c + 2] ^= 1;
                }
                seg[c] = e - s + 1 - seg[c];
                return;
            }
            int m = (s + e) >>> 1;
            update(s, m, 2 * c + 1, l, r);
            update(m + 1, e, 2 * c + 2, l, r);
            seg[c] = seg[2 * c + 1] + seg[2 * c + 2];
        }

        public static int getSum(int l, int r) {
            return getSum(0, N - 1, 0, l, r);
        }

        public static int getSum(int s, int e, int c, int l, int r) throws ArrayIndexOutOfBoundsException {
            if (lazy[c] != 0) {
                lazy[c] = 0;
                if (s != e) {
                    lazy[2 * c + 1] ^= 1;
                    lazy[2 * c + 2] ^= 1;
                }
                seg[c] = e - s + 1 - seg[c];
            }
            if (l > r || s > e || l > e || r < s) return 0;
            if (s >= l && e <= r) {
                return seg[c];
            }
            int m = (s + e) >>> 1;
            return getSum(s, m, 2 * c + 1, l, r) + getSum(m + 1, e, 2 * c + 2, l, r);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[8192];
        private int curChar;
        private int pnumChars;
        private FastReader.SpaceCharFilter filter;

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

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

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

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

        private boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

        private interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }

    static class GraphUtils {
        public static int[][] parentToG(int[] par) {
            int n = par.length;
            int[] ct = new int[n];
            for (int i = 0; i < n; i++) {
                if (par[i] >= 0) {
                    ct[i]++;
                    ct[par[i]]++;
                }
            }
            int[][] g = new int[n][];
            for (int i = 0; i < n; i++) {
                g[i] = new int[ct[i]];
            }
            for (int i = 0; i < n; i++) {
                if (par[i] >= 0) {
                    g[par[i]][--ct[par[i]]] = i;
                    g[i][--ct[i]] = par[i];
                }
            }
            return g;
        }

    }

    static class EulerTour {
        public int[] discover;
        public int[] begin;
        public int[] end;
        public int[] level;
        public int[] parent;
        public int[] indexes;

        public EulerTour(List<Integer>[] g, Object... objects) {
            int n = g.length;
            int[] stack = new int[n];
            int pos = 0;
            discover = new int[n];
            begin = new int[n];
            end = new int[n];
            level = new int[n];
            parent = new int[n];
            indexes = new int[n];
            boolean[] visited = new boolean[n];
            stack[pos++] = 0;
            level[0] = 0;
            parent[0] = -1;
            int clock = 0;
            int count = 0;
            outer:
            while (pos != 0) {
                int cur = stack[pos - 1];
                if (!visited[cur]) {
                    begin[cur] = clock++;
                    discover[count++] = cur;
                    visited[cur] = true;
                }
                while (indexes[cur] < g[cur].size()) {
                    int next = g[cur].get(indexes[cur]++);
                    if (parent[cur] != next) {
                        parent[next] = cur;
                        level[next] = level[cur] + 1;
                        stack[pos++] = next;
                        continue outer;
                    }
                }
                pos--;
                if (indexes[cur] == g[cur].size()) end[cur] = clock - 1;
            }
        }

        public EulerTour(int[][][] g) {
            int n = g.length;
            int[] stack = new int[n];
            int pos = 0;
            discover = new int[n];
            begin = new int[n];
            end = new int[n];
            level = new int[n];
            parent = new int[n];
            indexes = new int[n];
            boolean[] visited = new boolean[n];
            stack[pos++] = 0;
            level[0] = 0;
            parent[0] = -1;
            int clock = 0;
            int count = 0;
            outer:
            while (pos != 0) {
                int cur = stack[pos - 1];
                if (!visited[cur]) {
                    begin[cur] = clock++;
                    discover[count++] = cur;
                    visited[cur] = true;
                }
                while (indexes[cur] < g[cur].length) {
                    int next = g[cur][indexes[cur]++][0];
                    if (parent[cur] != next) {
                        parent[next] = cur;
                        level[next] = level[cur] + 1;
                        stack[pos++] = next;
                        continue outer;
                    }
                }
                pos--;
                if (indexes[cur] == g[cur].length) end[cur] = clock - 1;
            }
        }

        public EulerTour(int[][] g) {
            int n = g.length;
            int[] stack = new int[n];
            int pos = 0;
            discover = new int[n];
            begin = new int[n];
            end = new int[n];
            level = new int[n];
            parent = new int[n];
            indexes = new int[n];
            boolean[] visited = new boolean[n];
            stack[pos++] = 0;
            level[0] = 0;
            parent[0] = -1;
            int clock = 0;
            int count = 0;
            outer:
            while (pos != 0) {
                int cur = stack[pos - 1];
                if (!visited[cur]) {
                    begin[cur] = clock++;
                    discover[count++] = cur;
                    visited[cur] = true;
                }
                while (indexes[cur] < g[cur].length) {
                    int next = g[cur][indexes[cur]++];
                    if (parent[cur] != next) {
                        parent[next] = cur;
                        level[next] = level[cur] + 1;
                        stack[pos++] = next;
                        continue outer;
                    }
                }
                pos--;
                if (indexes[cur] == g[cur].length) end[cur] = clock - 1;
            }
        }

        public int[] getBegin() {
            return begin;
        }

        public int[] getEnd() {
            return end;
        }

    }
}