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.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 pandusonu
 */
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);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskE {
        public int tickTock;
        public int[][] time;
        public int[] t;
        public int[] a;
        public int[] tree;
        public int[] lazy;
        public boolean[] visited;
        public ArrayList<Integer>[] adlist;

        public TaskE() {
            tree = new int[2621450];
            lazy = new int[2621450];
        }

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            tickTock = 0;
            a = new int[n];
            visited = new boolean[n];
            time = new int[n][2];
            adlist = new ArrayList[n];
            for (int i = 0; i < n; i++) {
                adlist[i] = new ArrayList<>();
            }
            for (int i = 1; i < n; i++) {
                int u = in.readInt() - 1;
                adlist[u].add(i);
                adlist[i].add(u);
            }
            t = in.readIntArray(n);
            dfs(0);
            build(1, a, 0, n - 1);
            int q = in.readInt();
            for (int i = 0; i < q; i++) {
                String s = in.readString();
                int u = in.readInt() - 1;
                if (s.equals("get")) {
                    out.println(query(1, 0, n - 1, time[u][0], time[u][1]));
                } else {
                    updateLazy(1, 0, n - 1, time[u][0], time[u][1]);
                }
            }
        }

        public int query(int node, int start, int end, int l, int r) {
            if (l > end || r < start) return 0;
            if (lazy[node] != 0) {
                tree[node] = end - start + 1 - tree[node];
                if (start != end) {
                    lazy[node << 1] = 1 - lazy[node << 1];
                    lazy[node << 1 | 1] = 1 - lazy[node << 1 | 1];
                }
                lazy[node] = 0;
            }
            if (l <= start && end <= r) return tree[node];
            int mid = (start + end) / 2;
            int x = query(node << 1, start, mid, l, r);
            int y = query(node << 1 | 1, mid + 1, end, l, r);
            return x + y;
        }

        public void updateLazy(int node, int start, int end, int l, int r) {
            if (lazy[node] != 0) {
                tree[node] = end - start + 1 - tree[node];
                if (start != end) {
                    lazy[node << 1] = 1 - lazy[node << 1];
                    lazy[node << 1 | 1] = 1 - lazy[node << 1 | 1];
                }
                lazy[node] = 0;
            }
            if (l > end || r < start) return;
            if (l <= start && end <= r) {
                tree[node] = end - start + 1 - tree[node];
                if (start != end) {
                    lazy[node << 1] = 1 - lazy[node << 1];
                    lazy[node << 1 | 1] = 1 - lazy[node << 1 | 1];
                }
                return;
            }
            int mid = (start + end) / 2;
            updateLazy(node << 1, start, mid, l, r);
            updateLazy(node << 1 | 1, mid + 1, end, l, r);
            tree[node] = tree[node << 1] + tree[node << 1 | 1];
        }

        public void build(int node, int[] a, int start, int end) {
            if (start > end) return;
            if (start == end) {
                tree[node] = a[start];
                return;
            }
            int mid = (start + end) / 2;
            build(node << 1, a, start, mid);
            build(node << 1 | 1, a, mid + 1, end);
            tree[node] = tree[node << 1] + tree[node << 1 | 1];
        }

        public void dfs(int curr) {
            visited[curr] = true;
            a[tickTock] = t[curr];
            time[curr][0] = tickTock;
            tickTock++;
            for (int x : adlist[curr]) {
                if (!visited[x]) {
                    dfs(x);
                }
            }
            time[curr][1] = tickTock - 1;
        }

    }

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

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

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

        public int readInt() {
            return (int) readLong();
        }

        public long readLong() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
                if (c == -1) throw new RuntimeException();
            }
            boolean negative = false;
            if (c == '-') {
                negative = true;
                c = read();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9') throw new InputMismatchException();
                res *= 10;
                res += (c - '0');
                c = read();
            } while (!isSpaceChar(c));
            return negative ? (-res) : (res);
        }

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

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

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

    }
}