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.* ;
import java.util.stream.* ;
import java.text.* ;
import java.math.* ;
public class Codeshefcode{
	public static void main(String[] args) throws IOException{
		Solver Machine = new Solver() ;
		Machine.Solve() ;	
		Machine.Finish();
	}	
}
class Mod{
	static long mod=1000000007 ;
	static long d(long a,long b){ return (a*MI(b))%mod ; }
	static long m(long a , long b){ return (a*b)%mod ; }
	static private long MI(long a ){ return pow(a,mod-2) ; }
	static long pow(long a,long b){
		if(b<0) return pow(MI(a),-b) ;
		long val=a ; long ans=1 ;
		while(b!=0){
			if((b&1)==1) ans = (ans*val)%mod ; 
			val = (val*val)%mod ; 
			b>>=1 ;
		}
		return ans ;
	}	
}
class pair implements Comparable<pair>{
	long x ; long y ; 
	pair(long x,long y){ this.x=x ; this.y=y ;}
	public int compareTo(pair p){
		return (this.x<p.x ? -1 : (this.x>p.x ? 1 : (this.y<p.y ? -1 : (this.y>p.y ? 1 : 0)))) ;
	}
}
class Solver{	
	FasterScanner ip = new FasterScanner(System.in) ;	  
	PrintWriter op = new PrintWriter(System.out) ;
	int par[],t[],vis[],la[],ra[],seg[],arr[],lazy[] ;
	mylist adj[] ;
	void Solve() throws IOException{
		int n = ip.i() ;
		par = new int[n+1] ; t = new int[n+1] ; vis = new int[n+1] ;
		la = new int[n+1] ; ra = new int[n+1] ; adj = new mylist[n+1] ;		
		arr = new int[2*n+1] ; lazy = new int[10*n] ;
		seg = new int[10*n] ;
		for(int i=1 ; i<=n ; i++) adj[i] = new mylist() ;
		for(int i=2 ; i<=n ; i++){ 
			par[i] = ip.i() ;
			adj[par[i]].add(i) ;
		}
		for(int i=1 ; i<=n ; i++) t[i] = ip.i() ;
		mystack S = new mystack() ;
		int ptr=1 ;
		S.add(1) ;
		while(!S.isEmpty()){
			int nd = S.peek() ;
			if(vis[nd]==1){
				ra[nd]=ptr++ ;
				S.pop() ;
			}else{
				la[nd]=ptr++ ;
				vis[nd]=1 ;
				for(int nnd : adj[nd])
					S.push(nnd) ;
			}
		}
		for(int i=1 ; i<=n ; i++){
			arr[la[i]]=t[i] ;
			arr[ra[i]]=t[i] ;
 		}
 		build(1,1,2*n) ;
 		int q = ip.i() ;
 		while(q--!=0){
 			String s = ip.S() ;
 			if(s.compareTo("get")==0){
 				int nd = ip.i() ;
 				pln(query(1,1,2*n,la[nd],ra[nd])/2) ;
 			}else{
 				int nd = ip.i() ;
 				update(1,1,2*n,la[nd],ra[nd]) ;
 			}
 		}

	}
	void build(int n,int l,int r){
		if(l==r){seg[n]=arr[l] ; return ;}
		int m = (l+r)>>1 ;
		build(2*n,l,m) ; build(2*n+1,m+1,r) ;
		seg[n] = seg[2*n]+seg[2*n+1] ;
	}
	void rLazy(int n,int l,int r){
		if(lazy[n]==1){
			seg[n]=(r-l+1)-seg[n] ;
			if(l!=r){
				lazy[2*n]^=1 ;
				lazy[2*n+1]^=1 ; 
			}
			lazy[n]=0 ;
		}
	}
	void update(int n,int l,int r,int L,int R){
		rLazy(n,l,r) ;
		if(R<l || r<L) return ;
		if(L<=l && r<=R){
			lazy[n]^=1 ;
			rLazy(n,l,r) ;
			return ;
		}
		int m = (l+r)>>1 ;
		update(2*n,l,m,L,R) ; update(2*n+1,m+1,r,L,R) ;
		seg[n]=seg[2*n]+seg[2*n+1] ;
	}
	int query(int n,int l,int r,int L,int R){
		rLazy(n,l,r) ;
		if(R<l || r<L) return 0 ;
		if(L<=l && r<=R) return seg[n] ;
		int m = (l+r)>>1 ;
		return query(2*n,l,m,L,R)+query(2*n+1,m+1,r,L,R) ;
	}
	void p(Object o){
		op.print(o) ;
	}
	void pln(Object o){
		op.println(o) ;
	}
	void pArr(String name,Object arr,char type,int st){
		p(name+": [") ;
		if(type=='i'){ 
			int arr1[] = (int[]) arr ;
			for(int i=st ; i<arr1.length ; i++) p(arr1[i]+(i+1==arr1.length ? "" : ",")) ;		 
		}else if(type=='l'){ 
			long arr1[] = (long[]) arr ;
			for(int i=st ; i<arr1.length ; i++) p(arr1[i]+(i+1==arr1.length ? "" : ",")) ;
		}else if(type=='b'){
			boolean arr1[] = (boolean[]) arr ;
			for(int i=0 ; i<arr1.length ; i++) p((arr1[i] ? 1 : 0)+(i+1==arr1.length ? "" : ",")) ;
		}
		pln("]") ;
	}	
	void Finish(){
		op.flush();
		op.close();
	}	
}
@SuppressWarnings("serial")
class mylist extends ArrayList<Integer>{
}
@SuppressWarnings("serial")
class myset extends TreeSet<Long>{
 
}
@SuppressWarnings("serial")
class mystack extends Stack<Integer>{
}
@SuppressWarnings("serial")
class mymap extends TreeMap<Long,Integer>{
}
class FasterScanner { 
	private InputStream mIs;
	private byte[] buf = new byte[1024];
	private int curChar,numChars;
	public FasterScanner() { this(System.in); } 
	public FasterScanner(InputStream is) { mIs = is;} 
	public int read() {
		if (numChars == -1) throw new InputMismatchException();    
		if (curChar >= numChars) {
			curChar = 0;
			try { numChars = mIs.read(buf);} catch (IOException e) { throw new InputMismatchException();}
			if (numChars <= 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 S(){
		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 l(){
		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 i(){
		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[] ia(int n){
		int a[] = new int[n] ;
		for(int i=0 ; i<n ; i++) a[i] = i() ;
		return a ;
	}
	public long[] la(int n){
		long a[] = new long[n] ;
		for(int i=0 ; i<n ; i++) a[i] = l() ;
		return a ;
	}
	public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } 
	public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } 
}