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.*;
 
public class utkarsh {
 
    InputStream is;
    PrintWriter out;
    
    ArrayList<Integer> a[];
    int tin[], tout[], t, d[], tree[], lazy[], revt[];
    
    void dfs(int s){
        tin[s] = ++t;
        revt[t] = s;
        for(int x : a[s])   dfs(x);
        tout[s] = t;
    }
    
    void built(int n, int s, int e){
        if(s > e)   return;
        if(s == e){
            tree[n] = d[revt[s]];
            return;
        }
        int m = s + e >> 1;
        built(n + 1 + n, s, m);
        built(n + 2 + n, m + 1, e);
        tree[n] = tree[n + 1 + n] + tree[n + 2 + n];
    }
    
    void push(int n, int s, int e){
        if(lazy[n] == 1){
            tree[n] = (e - s + 1) - tree[n];
            if(s != e){
                lazy[n + 1 + n] ^= 1;
                lazy[n + 2 + n] ^= 1;
            }
            lazy[n] = 0;
        }
    }
    
    void update(int n, int s, int e, int l, int r){
        //System.out.println(n + " "+ s +" "+ e);
        if(s > e)   return;
        push(n, s, e);
        if(s > r || l > e)  return;
        if(l <= s && e <= r){
            tree[n] = (e - s + 1) - tree[n];
            if(s != e){
                lazy[n + 1 + n] ^= 1;
                lazy[n + 2 + n] ^= 1;
            }
            return;
        }
        int m = s + e >> 1;
        update(n + 1 + n, s, m, l, r);
        update(n + 2 + n, m+1, e, l, r);
        tree[n] = tree[n + 1 + n] + tree[n + 2 + n];
    }
    
    int query(int n, int s, int e, int l, int r){
        if(s > e)   return 0;
        push(n, s, e);
        if(s > r || l > e)  return 0;
        if(l <= s && e <= r)    return tree[n];
        int m = s + e >> 1;
        return query(n + 1 + n, s, m, l, r) + query(n + 2 + n, m+1, e, l, r);
    }
    
    void solve(){
        //Enter code here utkarsh
        int i, n;
        n = ni();
        a = new ArrayList[n];
        for(i = 0; i < n; i++)  a[i] = new ArrayList<>();
        for(i = 1; i < n; i++)  a[ni() - 1].add(i);
        t = -1;
        tin = new int[n];
        tout = new int[n];
        revt = new int[n];
        dfs(0);
        d = new int[n];
        for(i = 0; i < n; i++)  d[i] = ni();
        tree = new int[4 * n];
        lazy = new int[4 * n];
        built(0, 0, n-1);
        int q = ni();
        while(q-- > 0){
            if(ns().charAt(0) == 'g'){
                i = ni() - 1;
                out.println(query(0, 0, n-1, tin[i], tout[i]));
            }else{
                i = ni() - 1;
                //System.out.println(tin[i] +" "+ tout[i]);
                update(0, 0, n-1, tin[i], tout[i]);
            }
        }
    }
    
    public static void main(String[] args) { new utkarsh().run();
    }
    void run(){ is = System.in; out = new PrintWriter(System.out); solve(); out.flush();
    }
    
    byte input[] = new byte[1024];
    int len = 0, ptr = 0;
    
    int readByte(){ if(ptr >= len){ ptr = 0; try{ len = is.read(input); }catch(IOException e){ throw new InputMismatchException(); } if(len <= 0){ return -1; } } return input[ptr++];
    }
    boolean isSpaceChar(int c){ return !( c >= 33 && c <= 126 ); 
    }
    int skip(){ int b = readByte(); while(b != -1 && isSpaceChar(b)){ b = readByte(); } return b;
    }
    
    char nc(){ return (char)skip();
    }
    String ns(){ int b = skip(); StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString();
    }
    int ni(){ int n = 0,b = readByte(); boolean minus = false; while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')){ b = readByte(); } if(b == '-'){ minus = true; b = readByte(); } if(b == -1){ return -1; } while(b >= '0' && b <= '9'){ n = n * 10 + (b - '0'); b = readByte(); } return minus ? -n : n;
    }
    long nl(){ long n = 0L; int b = readByte(); boolean minus = false; while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')){ b = readByte(); } if(b == '-'){ minus = true; b = readByte(); } while(b >= '0' && b <= '9'){ n = n * 10 + (b - '0'); b = readByte(); } return minus ? -n : n;
    }
}