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.*;
import java.util.*;

/*
TASK: CFD
LANG: JAVA
 */
public class CFD {
    static int n , a , k;
    static ArrayList<Integer>[] tree;
    static int[] on , trav , first , last;
    static String choi;
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        n = in.nextInt();
        tree = new ArrayList[n];
        on = new int[n];
        first = new int[n];
        last = new int[n];
        trav = new int[2*n];
        for(int i = 0;i <n; i++)tree[i] = new ArrayList<Integer>();
        for(int i = 1; i < n ; i++){
             a = in.nextInt() - 1;
             tree[a].add(i);
        }
        for(int i = 0;i <n; i++)on[i] = in.nextInt();
        a = 0;
        init(0);
        a = in.nextInt();
        SegTree s = new SegTree(trav);
        for(int i = 0;i < a; i++){
            choi = in.next();
            k = in.nextInt() - 1;
            if(choi.equals("get")){
                System.out.println(s.sum(first[k] , last[k]) / 2);
            }
            else {
                s.flip(first[k] , last[k]);
            }
        }
    }

    private static class SegTree {
        int n;
        int[] lo, hi, sum , val;
        boolean[] propped;

        public SegTree(int[] a) {
            this.n = a.length;
            val = a;
            lo = new int[4 * n + 1];
            hi = new int[4 * n + 1];
            sum = new int[4*n + 1];
            propped = new boolean[4*n + 1];
            Arrays.fill(propped , true);
            init(1, 0, n - 1);

        }

        public int init(int i, int a, int b) {
            lo[i] = a;
            hi[i] = b;
            if (a == b){
                sum[i] = on[val[a]];
                return sum[i];
            }

            int m = (a + b) / 2;
            sum[i] = init(2 * i, a, m)  +  init(2 * i + 1, m + 1, b);
            return sum[i];
        }

        public void prop(int i) {
            if(!propped[i]) {
                propped[2*i] = !propped[2*i];
                sum[2*i] = (hi[2*i] - lo[2*i] + 1) - sum[2*i];
                propped[2*i+1] = !propped[2*i+1];
                sum[2*i + 1] = (hi[2*i+1] - lo[2*i + 1] + 1) - sum[2*i+1];
            }
            propped[i] = true;
        }
        public void update(int i){
            sum[i] = sum[2*i] + sum[2*i+1];
        }
        public void flip(int min, int max) { flip(1, min, max);}

        public void flip(int ind, int a, int b) {
            if (hi[ind] < a || lo[ind] > b) return;
            if (a <= lo[ind] && b >= hi[ind]) {
                propped[ind] = !propped[ind];
                sum[ind] = (hi[ind] - lo[ind] + 1) - sum[ind];
                return;
            }
            prop(ind);
            flip(2 * ind, a, b);
            flip(2 * ind + 1, a, b);
            update(ind);
        }

        public int sum(int min, int max) {
            return sum(1, min, max);
        }

        public int sum(int ind, int a, int b) {
            if (hi[ind] < a || lo[ind] > b) return 0;
            if (a <= lo[ind] && b >= hi[ind]) {
                return sum[ind];
            }
            prop(ind);
            int s1 = sum(2*ind , a , b) +  sum(2*ind + 1 , a , b);
            update(ind);
            return s1;
        }
    }
    public static void init(int i ){
        first[i] = a;
        trav[a++] = i;
        for(int k : tree[i]){
            init(k);
        }
        last[i] = a;
        trav[a++] = i;
    }

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

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

        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++];
        }

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

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        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();
        }

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