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

public class DanilPartTimeJobs {
    static int[] inVal;
    static int[] outVal;
    static int cnt = -1;
    static ArrayList<Integer>[] graph;
    public static void main(String[] args) {
        FastScanner scanner = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);
        int N = scanner.nextInt();
        graph = new ArrayList[N];
        inVal = new int[N];
        outVal = new int[N];
        for(int i = 0; i < N; i++) graph[i] = new ArrayList<>();
        for(int i =1; i < N; i++) graph[scanner.nextInt()-1].add(i);
        SegTree sg = new SegTree(N, 0, N-1);
        dfs(0);
        for(int i = 0; i < N; i++) {
            int n = scanner.nextInt();
            if (n == 1) sg.increment(1, inVal[i], inVal[i], n);
        }
        int Q = scanner.nextInt();
        while(Q-->0) {
            String op = scanner.next();
            int v = scanner.nextInt()-1;
            if (op.charAt(0) == 'g') {
                out.println(sg.query(1, inVal[v], outVal[v]));
            }
            else {
                sg.increment(1, inVal[v], outVal[v], 1);
            }
        }
        out.flush();
    }
    
    static void dfs(int v) {
        inVal[v] = ++cnt;
        for(int edge: graph[v]) {
            dfs(edge);
        }
        outVal[v] = cnt;
    }
    
    static class SegTree {
        int[] hi, lo;
        int[] delta, sum;
        public SegTree(int ss, int l, int r) {
            hi = new int[4 * ss + 1];
            lo = new int[4 * ss + 1];
            delta = new int[4 * ss + 1];
            sum = new int[4 * ss + 1];
            init(1, l, r);
        }
        public void init(int cur, int l, int r) {
            hi[cur] = r;
            lo[cur] = l;
            if (r == l) return;
            int mid = (l + r)/2;
            init(cur * 2, l, mid);
            init(cur*2 + 1, mid + 1, r);
        }
        public void increment(int cur, int l, int r, int amt) {
            if (l > hi[cur] || r < lo[cur]) return;
            if (r >= hi[cur] && l <= lo[cur]) {
                delta[cur]+= amt;
                return;
            }
            prop(cur);
            increment(cur * 2, l, r, amt);
            increment(cur*2 + 1, l, r, amt);
            update(cur);
        }
        public void prop(int cur) {
            delta[cur*2] += delta[cur];
            delta[cur*2] %= 2;
            delta[cur*2 + 1] += delta[cur];
            delta[cur*2 + 1] %= 2;
            delta[cur] = 0;
        }
        public int query(int cur, int l, int r) {
            if (hi[cur] < l || lo[cur] > r) return 0;
            if (r >= hi[cur] && l <= lo[cur]) {
                if (delta[cur] % 2 == 0) return sum[cur];
                else return (hi[cur] - lo[cur] + 1) - sum[cur];
            }
            prop(cur);
            int l1 = query(cur*2, l, r);
            int l2 = query(cur*2 + 1, l, r);
            update(cur);
            return l1 + l2;
        }
        public void update(int cur) {
            sum[cur] = 0;
            if (delta[cur*2] % 2 == 0) sum[cur] += sum[cur*2];
            else sum[cur] += (hi[cur*2] - lo[cur*2] + 1) - sum[cur*2];
            if (delta[cur*2+1] % 2 == 0) sum[cur] += sum[cur*2+1];
            else sum[cur] += (hi[cur*2+1] - lo[cur*2+1] + 1) - sum[cur*2+1];
        }
    }
    
    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }
        
        public FastScanner() {
            this(new InputStreamReader(System.in));
        }
        
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        
        int nextInt() {
            return Integer.parseInt(next());
        }
        
        long nextLong() {
            return Long.parseLong(next());
        }
        
        double nextDouble() {
            return Double.parseDouble(next());
        }
        
        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
        
        int[] readIntArray(int n) {
            int[] a = new int[n];
            for (int idx = 0; idx < n; idx++) {
                a[idx] = nextInt();
            }
            return a;
        }
    }
}