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

    static class danilAndPartTimejob {
        static ArrayList<Integer>[] adj;
        static int N = (int) 3e5 + 5;
        static int[] st = new int[4 * N];
        static boolean[] lazy = new boolean[4 * N];
        static int time = 0;
        static int[] reversal = new int[N];
        static int[] start = new int[N];
        static int[] fin = new int[N];
        static int[] array = new int[N];
        static int n;

        public void solve(int testNumber, InputReader scan, OutputWriter out) {
            n = scan.nextInt();
            adj = new ArrayList[n + 1];
            for (int i = 0; i <= n; i++) {
                adj[i] = new ArrayList<>();
            }
            for (int i = 2; i <= n; i++) {
                adj[scan.nextInt()].add(i);
            }
            for (int i = 1; i <= n; i++) {
                array[i] = scan.nextInt();
            }
            dfs(1);
            build(1, 1, n);
            int q = scan.nextInt();
            while (q-- > 0) {
                String s = scan.next();
                if (s.charAt(0) == 'g') {
                    int a = scan.nextInt();
                    out.println(query(start[a], fin[a]));
                } else {
                    int a = scan.nextInt();
                    update(start[a], fin[a]);
                }
            }
        }

        private void dfs(int p) {
            start[p] = ++time;
            reversal[time] = p;
            for (int v : adj[p]) {
                dfs(v);
            }
            fin[p] = time;
        }

        void build(int p, int l, int r) {
            if (l == r) {
                st[p] = array[reversal[l]];
                return;
            }
            int mid = (r + l) >> 1;
            build(left(p), l, mid);
            build(right(p), mid + 1, r);
            int p1 = st[left(p)];
            int p2 = st[right(p)];
            st[p] = p1 + p2;
        }

        void update(int p, int l, int r, int i, int j) {
            join(p, l, r);
            if (i > r || j < l) {
                return;
            }
            if (i <= l && j >= r) {
                lazy[p] ^= true;
                join(p, l, r);
                return;
            }
            int mid = (r + l) >> 1;
            update(left(p), l, mid, i, j);
            update(right(p), mid + 1, r, i, j);
            int p1 = st[left(p)];
            int p2 = st[right(p)];
            st[p] = p1 + p2;
        }

        void update(int i, int j) {
            update(1, 1, n, i, j);
        }

        int query(int p, int l, int r, int i, int j) {
            join(p, l, r);
            if (i > r || j < l) {
                return 0;
            }
            if (i <= l && j >= r) {
                return st[p];
            }
            int mid = (r + l) >> 1;


            int p1 = query(left(p), l, mid, i, j);
            int p2 = query(right(p), mid + 1, r, i, j);
            return p1 + p2;
        }

        int query(int l, int r) {
            return query(1, 1, n, l, r);
        }

        void join(int p, int l, int r) {
            if (lazy[p]) {
                st[p] = (r - l + 1) - st[p];
                if (l != r) {
                    lazy[left(p)] ^= true;
                    lazy[right(p)] ^= true;
                }
                lazy[p] = false;
            }
        }

        int left(int p) {
            return p << 1;
        }

        int right(int p) {
            return p << 1 | 1;
        }

    }

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

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

        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 *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

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

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

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

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

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

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

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

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

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

        public void println(int i) {
            writer.println(i);
        }

    }
}