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 E implements Runnable{
	public static void main (String[] args) {new Thread(null, new E(), "_cf", 1 << 28).start();}

	public void run() {
		FastScanner fs = new FastScanner();
		PrintWriter out = new PrintWriter(System.out);

		n = fs.nextInt();
		adj = new ArrayList[n];
		for(int i = 0; i < n; i++)
			adj[i] = new ArrayList<>();
		
		String[] split = fs.nextLine().split(" ");
		for(int i = 1; i < n; i++)
			adj[Integer.parseInt(split[i-1])-1].add(i);
		order = new int[2*n];
		start = new int[n];
		end = new int[n];
		sums = new int[n];
		size = new int[n];

		a = new int[n];
		for(int i = 0; i < n; i++)
			a[i] = fs.nextInt();

		dfs(0);

		Segment_Tree st = new Segment_Tree(2 * n);
		for(int i = 0; i < 2 * n; i++) {
			if(a[order[i]] == 1) {
				st.increment(1, i, i, 0, 2*n-1);
			}
		}
		
		int q = fs.nextInt();
		while(q-->0) {
			char c = fs.next().charAt(0);
			int v = fs.nextInt()-1;
			
			if(c == 'g') {
				out.println(st.sum(1, start[v], end[v], 0, 2*n-1, 0)/2);
			} else {
				st.increment(1, start[v], end[v], 0, 2*n-1);
			}
		}

		out.close();
	}

	int dfs (int u) {
		int sum = 0;
		start[u] = time;
		order[time++] = u;
		for(Integer i : adj[u]) {
			sum += dfs(i);
			size[u] += size[i];
		}
		end[u] = time;
		order[time++] = u;
		size[u]++;
		return sums[u] = a[u] + sum;
	}

	ArrayList<Integer>[] adj;
	int[] order, start, end;
	int[] sums, size, a;
	int n, time = 0;

	public class Segment_Tree {
		int[] flipped;
		int[] on;
		int n;
		
		public Segment_Tree(int a) {
			n = 4 * a + 100;
			flipped = new int[n];
			on = new int[n];
		}
		
		int left (int p) {return p << 1;}
		int right (int p) {return (p << 1) + 1;}

		void increment (int p, int a, int b, int l, int r) {
			if(a > r || b < l) {
				return;
			}
			
			if(a <= l && r <= b) {
				flipped[p] ^= 1;
				return;
			}

			if(l == r) return;
			
			int mid = (l + r) / 2;
			increment(left(p), a, b, l, mid);
			increment(right(p), a, b, mid+1, r);
			
			int res = 0;
			
			if(flipped[left(p)] == 0) {
				res += on[left(p)];
			} else {
				int len = mid - l + 1;
				res += len - on[left(p)];
			}
			
			if(flipped[right(p)] == 0) {
				res += on[right(p)];
			} else {
				int len = r - (mid+1) + 1;
				res += len - on[right(p)];
			}
			
			on[p] = res;
			
		}
		
		int sum (int p, int a, int b, int l, int r, int xor) {
			if(a > r || b < l) {
				return 0;
			}
			
			if(a <= l && r <= b) {
				if((xor^flipped[p]) == 0) {
					return on[p];
				} else {
					return (r-l+1) - on[p];
				}
			}

			int mid = (l + r) / 2;
			int res = 0;
			res += sum(left(p), a, b, l, mid, xor^flipped[p]); //transfer the flipped state down the tree
			res += sum(right(p), a, b, mid+1, r, xor^flipped[p]); //Same as above

			return res;
		}
		
	}
	void sort (int[] a) {
		int n = a.length;
		for(int i = 0; i < 1000; i++) {
			Random r = new Random();
			int x = r.nextInt(n), y = r.nextInt(n);
			int temp = a[x];
			a[x] = a[y];
			a[y] = temp;
		}
		Arrays.sort(a);
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		public FastScanner() {
			try	{
				br = new BufferedReader(new InputStreamReader(System.in));
				//				br = new BufferedReader(new FileReader("testdata.out"));
				st = new StringTokenizer("");
			} catch (Exception e){e.printStackTrace();}
		}
		public String next() {
			if (st.hasMoreTokens())	return st.nextToken();
			try {st = new StringTokenizer(br.readLine());}
			catch (Exception e) {e.printStackTrace();}
			return st.nextToken();
		}
		public int nextInt() {return Integer.parseInt(next());}
		public long nextLong() {return Long.parseLong(next());}
		public double nextDouble() {return Double.parseDouble(next());}

		public String nextLine() {
			String line = "";
			try {line = br.readLine();}
			catch (Exception e) {e.printStackTrace();}
			return line;
		}
		public Integer[] nextIntegerArray(int n) {
			Integer[] a = new Integer[n];
			for(int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for(int i = 0; i < n; i++) a[i] = nextInt();
			return a;
		}
		public char[] nextCharArray() {return nextLine().toCharArray();}
	}

}