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:
/**
 * DA-IICT
 * Author : PARTH PATEL
 */
import java.io.*;
import java.math.*;
import java.util.*;


import static java.util.Arrays.fill;
import static java.lang.Math.*;
import static java.util.Arrays.sort;
import static java.util.Collections.sort;


public class E877 
{

	public static int mod = 1000000007;
	static FasterScanner in = new FasterScanner();
	static PrintWriter out = new PrintWriter(System.out);
	static int time=0;
	static int[] tin;
	static int[] tout;
	static ArrayList<Integer>[] adjacencylist;
	static boolean[] visited;
	static class Node
	{
		int on=0;
		int off=0;
	}
	static Node[] tree;
	static int[] lazy;
	public static void dfs(int vertex)
	{
		visited[vertex]=true;
		tin[vertex]=time++;
		for(int i : adjacencylist[vertex])
		{
			if(!visited[i])
				dfs(i);
		}
		tout[vertex]=time++;
	}
	static int[] ison;
	static int[] arr;
	public static void build(int node,int start,int end)
	{
		if(start==end)
		{
			tree[node].off=1-ison[arr[start]];
			tree[node].on=ison[arr[start]];
		}
		else
		{
			int mid=(start+end)/2;
			build(2*node, start, mid);
			build(2*node+1, mid+1, end);
			tree[node].on=tree[2*node].on+tree[2*node+1].on;
			tree[node].off=tree[2*node].off+tree[2*node+1].off;
		}
	}
	public static void updaterange(int node,int start,int end,int l,int r)
	{
		lazy[node]%=2;
		if(lazy[node]!=0)
		{
			int temp=tree[node].on;
			tree[node].on=tree[node].off;
			tree[node].off=temp;
			if(start!=end)
			{
				lazy[2*node]+=lazy[node];
				lazy[2*node+1]+=lazy[node];
				lazy[2*node]%=2;
				lazy[2*node+1]%=2;
			}
			lazy[node]=0;
		}
		if(start>r || end<l)
		{
			return;
		}
		if(start>=l && end<=r)
		{
			int temp=tree[node].on;
			tree[node].on=tree[node].off;
			tree[node].off=temp;
			if(start!=end)
			{
				lazy[2*node]+=1;
				lazy[2*node+1]+=1;
				lazy[2*node]%=2;
				lazy[2*node+1]%=2;
			}
			return;
		}
		int mid=(start+end)/2;
		updaterange(2*node, start, mid, l, r);
		updaterange(2*node+1, mid+1, end, l, r);
		tree[node].on=tree[2*node].on+tree[2*node+1].on;
		tree[node].off=tree[2*node].off+tree[2*node+1].off;
	}
	public static int queryrange(int node,int start,int end,int l,int r)
	{
		lazy[node]%=2;
		if(lazy[node]!=0)
		{
			int temp=tree[node].on;
			tree[node].on=tree[node].off;
			tree[node].off=temp;
			if(start!=end)
			{
				lazy[2*node]+=1;
				lazy[2*node+1]+=1;
				lazy[2*node]%=2;
				lazy[2*node+1]%=2;
			}
			lazy[node]=0;
		}
		if(start>r || end<l)
			{
			return 0;
			}
		if(start>=l && end<=r)
		{
			return tree[node].on;
		}
		int mid=(start+end)/2;
		int p1=queryrange(2*node, start, mid, l, r);
		int p2=queryrange(2*node+1, mid+1, end, l, r);
		return (p1+p2);
	}
	public static void main(String[] args) 
	{
		int n=in.nextInt();
		tin=new int[n+1];
		tout=new int[n+1];
		adjacencylist=new ArrayList[n+1];
		visited=new boolean[n+1];
		ison=new int[n+1];
		arr=new int[2*n];
		for(int i=1;i<=n;i++)
		{
			adjacencylist[i]=new ArrayList<>();
		}
		for(int i=1;i<n;i++)
		{
			int p=in.nextInt();
			adjacencylist[i+1].add(p);
			adjacencylist[p].add(i+1);
		}
		for(int i=1;i<=n;i++)
		{
			ison[i]=in.nextInt();
		}
		dfs(1);
		//System.out.println(tin[1]+" tin[1]");
		for(int i=1;i<=n;i++)
		{
			//System.out.println(tin[i]+" "+tout[i]);
			arr[tin[i]]=i;
			arr[tout[i]]=i;
		}
		tree=new Node[4*2*n];
		lazy=new int[4*2*n];
		for(int i=0;i<8*n;i++)
		{
			tree[i]=new Node();
		}
		build(1, 0, 2*n-1);
		int queries=in.nextInt();
		while(queries-->0)
		{
			String s=in.nextString();
			if(s.equals("get"))
			{
				int x=in.nextInt();
				int l=tin[x];
				int r=tout[x];
				//out.println(l+" "+r);
				int answer=queryrange(1, 0, 2*n-1, l, r);
				answer/=2;
				out.println(answer);
			}
			else
			{
				int x=in.nextInt();
				int l=tin[x];
				int r=tout[x];
				updaterange(1, 0, 2*n-1, l, r);
			}
		}
		out.close();

	}
	

	
	
	public static long pow(long x, long n, long mod) 
	{
		long res = 1;
		for (long p = x; n > 0; n >>= 1, p = (p * p) % mod) 
		{
			if ((n & 1) != 0) 
			{
				res = (res * p % mod);
			}
		}
		return res;
	}

	public static long gcd(long n1, long n2) 
	{
		long r;
		while (n2 != 0) 
		{
			r = n1 % n2;
			n1 = n2;
			n2 = r;
		}
		return n1;
	}

	public static long lcm(long n1, long n2) 
	{
		long answer = (n1 * n2) / (gcd(n1, n2));
		return answer;
	}

	static class FasterScanner 
	{
		private byte[] buf = new byte[1024];
		private int curChar;
		private int snumChars;

		public int read() 
		{
			if (snumChars == -1)
				throw new InputMismatchException();
			if (curChar >= snumChars) 
			{
				curChar = 0;
				try 
				{
					snumChars = System.in.read(buf);
				} catch (IOException e) 
				{
					throw new InputMismatchException();
				}
				if (snumChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() 
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do 
			{
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() 
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do 
			{
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() 
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') 
			{
				sgn = -1;
				c = read();
			}
			long res = 0;
			do 
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} 
			while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() 
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') 
			{
				sgn = -1;
				c = read();
			}
			int res = 0;
			do 
			{
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} 
			while (!isSpaceChar(c));
			return res * sgn;
		}

		public int[] nextIntArray(int n) 
		{
			int[] arr = new int[n];
			for (int i = 0; i < n; i++) 
			{
				arr[i] = nextInt();
			}
			return arr;
		}

		public long[] nextLongArray(int n) 
		{
			long[] arr = new long[n];
			for (int i = 0; i < n; i++)
			{
				arr[i] = nextLong();
			}
			return arr;
		}

		private boolean isSpaceChar(int c) 
		{
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) 
		{
			return c == '\n' || c == '\r' || c == -1;
		}
	}

}