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.util.*;
import java.math.*;
import java.io.*;
public class Main {
	InputStream is;
    PrintWriter out;
    
    
	int seg[],l[],r[],lazy[],n,fa[];
	int timecnt=0;
	ArrayList<Integer> G[];
	Scanner cin=new Scanner(System.in);
	
	int find(int x) {
		if(fa[x]==0) return x;
		return find(fa[x]);
	}
	void dfs(int u,int pa) {
		//System.out.println(u);
		l[u]=++timecnt;
		for(int v:G[u]) {
			if(v==pa) continue;
			dfs(v,u);
		}
		r[u]=timecnt;
	}
	void push_up(int root,int l,int r) {
		seg[root]=seg[root<<1]+seg[root<<1|1];
	}
	void push_down(int root,int l,int r) {
		if((lazy[root]&1)==1) {
			int mid=(l+r)>>1;
			seg[root<<1]=(mid-l+1)-seg[root<<1];
			seg[root<<1|1]=(r-mid)-seg[root<<1|1];
			lazy[root<<1]+=lazy[root];
			lazy[root<<1|1]+=lazy[root];
		}
		lazy[root]=0;
	}
	void update(int root,int l,int r,int ql,int qr) {
		if(l>qr||r<ql) return ;
		if(l>=ql&&r<=qr) {
			seg[root]=(r-l+1)-seg[root];
			lazy[root]+=1;
			return ;
		}
		int mid=(l+r)>>1;
		push_down(root,l,r);
		update(root<<1,l,mid,ql,qr);
		update(root<<1|1,mid+1,r,ql,qr);
		push_up(root,l,r);
		return ;
	}
	int query(int root,int l,int r,int ql,int qr) {
		if(l>qr||r<ql) return 0;
		if(l>=ql&&r<=qr) {
			return seg[root];
		}
		int mid=(l+r)>>1;
		push_down(root,l,r);
		int res=0;
		res+=query(root<<1,l,mid,ql,qr);
		res+=query(root<<1|1,mid+1,r,ql,qr);
		push_up(root,l,r);
		return res;
	}
	void solve() {
		// TODO Auto-generated method stub
		is = System.in; out = new PrintWriter(System.out);
		n=ni();
		G=new ArrayList[n+1];
		fa=new int[n+1];
		seg=new int[8*n+1];
		lazy=new int[8*n+1];
		l=new int[2*n+1];
		r=new int[2*n+1];
		for(int i=1;i<=n;i++) G[i]=new ArrayList<>();
		
		
		for(int i=2;i<=n;i++) {
			int x=ni();
			fa[i]=x;
			G[i].add(x);
			G[x].add(i);
		}
		int root=find(1);
		dfs(root,root);
		for(int i=1;i<=n;i++) {
			int x=ni();
			if(x==1) {
				update(1,1,timecnt,l[i],l[i]);
			}
		}
		int m=ni();
		while(m>0) {
			m--;
			//System.out.println(x);

			if(ns().charAt(0)=='g') {
				int tmp=ni();
				//System.out.println("yes");
				System.out.println(query(1,1,timecnt,l[tmp],r[tmp]));
			}
			else {
				int tmp=ni();
				update(1,1,timecnt,l[tmp],r[tmp]);
			}
		}
	}
	public static void main(String[] args) {
		new Main().solve();
	}
	
	
	
	
	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;
    }
	
}