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

public class E {
	static ArrayList<Integer> tour;
	static ArrayList<ArrayList<Integer>> tree;
	static int[] l;
	static int[] r;
	public static void main(String[] args) {
		FastReader fr = new FastReader();
		int n = fr.nextInt();
		l = new int[n];
		r = new int[n];
		tree = new ArrayList<ArrayList<Integer>>();
		for(int i = 0; i < n; i++){
			tree.add(new ArrayList<Integer>());
		}
		for(int i = 1; i < n; i++){
			int p = fr.nextInt()-1;
			tree.get(p).add(i);
		}
		int[] on = new int[n];
		for(int i = 0; i < n; i++){
			on[i] = fr.nextInt();
		}
		tour = new ArrayList<Integer>(2*n);
		dfs(0);
		ArrayList<Integer> ontour = new ArrayList<Integer>(2*n);
		for(int i = 0; i < tour.size(); i++){
			ontour.add(on[tour.get(i)]);
		}
		RangeSegmentTree rst = new RangeSegmentTree(ontour);
		int q = fr.nextInt();
		for(int i = 0; i < q; i++){
			String s = fr.next();
			int j = fr.nextInt()-1;
			if(s.equals("get")) System.out.println(rst.query(l[j], r[j])/2);
			else rst.update(l[j], r[j], 1);
		}
	}

	static void dfs(int p){
		l[p] = tour.size();
		tour.add(p);
		for(int c:tree.get(p)){
			dfs(c);
		}
		r[p] = tour.size();
		tour.add(p);
	}
}

class FastReader{
	BufferedReader br;
	StringTokenizer st;

	FastReader(){
		br = new BufferedReader(new InputStreamReader(System.in));
	}

	String next(){
		while(st==null || !st.hasMoreTokens()){
			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 nextLine(){
		String str = "";
		try{
			str = br.readLine();
		}catch(IOException e){
			e.printStackTrace();
		}
		return str;
	}
}

//source: http://www.geeksforgeeks.org/fast-io-in-java-in-competitive-programming/

/**
 * A segment tree for range minimum queries with range updates and queries
 */
class RangeSegmentTree{

  //The Segment Tree is built using an array
  int[] st;
  //Number of leaf elements being held
  //Not the same as the number of elements in the entire st.
  int size;
  //Needed for lazy propogation.
  int[] update;

  public RangeSegmentTree(ArrayList<Integer> list){
    size = list.size();
    st = new int[4*size];
    update = new int[4*size];
    build(list, 0, size - 1, 0);
  }
  /**
   * n is the index of the current tree node being built.
   * nl are nr are the ranges whose min value is held in node n.
   */
  private void build(ArrayList<Integer> list, int nl, int nr, int n){
    if(nl == nr){
      st[n] = list.get(nl);
    }else{
      int left = left(n);
      int right = right(n);
      int mid = (nl+nr)/2;
      build(list, nl, mid, left);
      build(list, mid + 1, nr, right);
      st[n] = st[left] + st[right];
    }
  }

  /**
   * Get left child
   */
  private int left(int n){
    return 2*n+1;
  }

  /**
   * Get right child
   */
  private int right(int n){
    return 2*n+2;
  }

  /**
   * Find the minimum on the range l - r.
   */
  public int query(int l, int r){
    return query(0, size - 1, l, r, 0);
  }

  private int query(int nl, int nr, int l, int r, int n){
    if(update[n] != 0){
      st[n] = update[n] % 2 == 1 ? nr-nl+1-st[n] : st[n];
      if(nl != nr){
        update[left(n)] += update[n];
        update[right(n)] += update[n];
      }
      update[n] = 0;
    }
    if(l == nl && r == nr){
      return st[n];
    }
    int mid = (nl+nr)/2;
    int left = left(n);
    int right = right(n);
    if(l <= mid && mid + 1 <= r){
      int a = query(nl, mid, l, mid, left);
      int b = query(mid + 1, nr, mid+1, r, right);
      return a+b;
    }
    if(r <= mid){
      return query(nl, mid, l, r, left);
    }else if(mid + 1 <= l){
      return query(mid + 1, nr, l, r, right);
    }
    System.out.println(l + " " + r + " " + nl + " " +  mid + " " + nr);
    return -12131242;
  }

  public void update(int l, int r, int value){
    update(0, size - 1, 0, l, r, value);
  }

  private void update(int nl, int nr, int n, int l, int r, int value){
    if(update[n] != 0){
      st[n] = update[n] % 2 == 1 ? nr-nl+1-st[n] : st[n];
      if(nl != nr){
        update[left(n)] += update[n];
        update[right(n)] += update[n];
      }
      update[n] = 0;
    }
    if(l == nl && r == nr){
      st[n] = value % 2 == 1 ? nr-nl+1-st[n] : st[n];
      if(l != r){
        update[left(n)] += value;
        update[right(n)] += value;
      }
      return;
    }
    int mid = (nl+nr)/2;
    int left = left(n);
    int right = right(n);
    if(l <= mid && mid + 1 <= r){
      update(nl, mid, left, l, mid, value);
      update(mid + 1, nr, right, mid + 1, r, value);
      int a = query(nl, mid, nl, mid, left);
      int b = query(mid + 1, nr, mid + 1, nr, right);
      st[n] = a + b;
      return;
    }
    if(r <= mid){
      update(nl, mid, left, l, r, value);
      int a = query(nl, mid, nl, mid, left);
      int b = query(mid + 1, nr, mid+1, nr, right);
      st[n] = a + b;
      return;
    }else if(mid + 1 <= l){
      update(mid + 1, nr, right, l, r, value);
      int a = query(nl, mid, nl, mid, left);
      int b = query(mid + 1, nr, mid+1, nr, right);
      st[n] = a + b;
      return;
    }
    System.out.println(l + " " + r + " " + nl + " " +  mid + " " + nr);
  }
  public String toString(){
  	return Arrays.toString(st);
  }
}
