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

public class Template implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    void init() throws FileNotFoundException {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            try {
                tok = new StringTokenizer(in.readLine(), " :");
            } catch (Exception e) {
                return null;
            }
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] res = new int[size];
        for (int i = 0; i < size; i++) {
            res[i] = readInt();
        }
        return res;
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    <T> List<T>[] createGraphList(int size) {
        List<T>[] list = new List[size];
        for (int i = 0; i < size; i++) {
            list[i] = new ArrayList<>();
        }
        return list;
    }

    public static void main(String[] args) {
        new Template().run();
//        new Thread(null, new Template(), "", 1l * 200 * 1024 * 1024).start();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    long memoryTotal, memoryFree;

    void memory() {
        memoryFree = Runtime.getRuntime().freeMemory();
        System.err.println("Memory = " + ((memoryTotal - memoryFree) >> 10)
                + " KB");
    }

    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            memoryTotal = Runtime.getRuntime().freeMemory();
            init();
            solve();
            out.close();
            if (System.getProperty("ONLINE_JUDGE") == null) {
                time();
                memory();
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }


    int[] left;
    int[] right;
    int time;
    List<Integer>[] g;

    void dfs(int v) {
        left[v] = time++;
        for (int y : g[v]) {
            dfs(y);
        }
        right[v] = time - 1;
    }

    class SegmentTree {
        int[] on;
        boolean[] push;
        int n;

        SegmentTree(int[] t) {
            on = new int[4 * t.length];
            push = new boolean[4 * t.length];
            src = t;
            build(1, 0, t.length - 1);
            this.n = t.length;
        }

        int[] src;

        void build(int v, int tl, int tr) {
            if (tl == tr) {
                if (src[tl] == 0) {
                } else {
                    on[v] = 1;
                }
                return;
            }
            int mid = (tl + tr) >> 1;
            build(v * 2, tl, mid);
            build(v * 2 + 1, mid + 1, tr);
            on[v] = on[v * 2] + on[v * 2 + 1];
        }

        void push(int v, int tl, int tr) {
            if (!push[v]) return;
            if (tl == tr) {
                on[v] = 1 - on[v];
                push[v] = false;
                return;
            }
            int len = tr - tl + 1;
            on[v] = len - on[v];
            push[v * 2] ^= true;
            push[v * 2 + 1] ^= true;
            push[v] = false;
        }

        void swit(int v, int tl, int tr, int l, int r) {
            push(v, tl, tr);
            if (tl == l && tr == r) {
                push[v] = true;
                return;
            }
            int mid = (tl + tr) >> 1;
            if (r <= mid) {
                swit(v * 2, tl, mid, l, r);
            } else if (l > mid) {
                swit(v * 2 + 1, mid + 1, tr, l, r);
            } else {
                swit(v * 2, tl, mid, l, mid);
                swit(v * 2 + 1, mid + 1, tr, mid + 1, r);
            }
            push(v * 2, tl, mid);
            push(v * 2 + 1, mid + 1, tr);
            on[v] = on[v * 2] + on[v * 2 + 1];
        }

        int get(int v, int tl, int tr, int l, int r) {
            push(v, tl, tr);
            if (tl == l && tr == r) {
                return on[v];
            }
            int mid = (tl + tr) >> 1;
            if (r <= mid) return get(v * 2, tl, mid, l, r);
            if (l > mid) return get(v * 2 + 1, mid + 1, tr, l, r);
            return get(v * 2, tl, mid, l, mid) + get(v * 2 + 1, mid + 1, tr, mid + 1, r);
        }
    }

    void solve() throws IOException {
        int n = readInt();
        left = new int[n];
        right = new int[n];
        g = new List[n];
        for (int i = 0; i < n; i++) {
            g[i] = new ArrayList<>();
        }
        for (int i = 1; i < n; i++) {
            int p = readInt() - 1;
            g[p].add(i);
        }
        dfs(0);
        int[] tt = readIntArray(n);
        int[] nt = new int[tt.length];
        for (int i = 0; i < tt.length; i++) {
            nt[left[i]] = tt[i];
        }
        SegmentTree segmentTree = new SegmentTree(nt);
        int q = readInt();
        int[] ttt = tt.clone();
        while (q-- > 0) {
            String t = readString();
            int v = readInt() - 1;
            int l = left[v];
            int r = right[v];
            if (t.equals("pow")) {
//                stupidSwitch(ttt, v);
                segmentTree.swit(1, 0, tt.length - 1, l, r);
            } else {
//                int str = stupidAns(ttt, v);
                int clev = segmentTree.get(1, 0, tt.length - 1, l, r);
//                if (str != clev) {
//                    throw new RuntimeException(str + " " + clev);
//                }
                out.println(clev);
            }
        }
    }

    void stupidSwitch(int[] on, int v) {
        on[v] = 1 - on[v];
        for (int y : g[v]) {
            stupidSwitch(on, y);
        }
    }

    int stupidAns(int[] on, int v) {
        int res = on[v];
        for (int y : g[v]) {
            res += stupidAns(on, y);
        }
        return res;
    }
}