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.util.*;
import java.util.concurrent.TimeUnit;

public class e442 implements Runnable{
	
    public static void main(String[] args) {
    	try{
            new Thread(null, new e442(), "process", 1<<26).start();
        }
        catch(Exception e){
            System.out.println(e);
        }
    }
	public void run() {
		FastReader scan = new FastReader();
        PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		//PrintWriter out = new PrintWriter("file.out");
		Task solver = new Task();
		//int t = scan.nextInt();
		int t = 1;
		for(int i = 1; i <= t; i++) solver.solve(i, scan, out);
		out.close();
	}

	static class Task {
		static final int inf = Integer.MAX_VALUE;

		static List<List<Integer>> adj = new ArrayList<>();
		static int[] switches;
		public void solve(int testNumber, FastReader sc, PrintWriter out) {
			int N = sc.nextInt();
			for(int i = 0; i <= N; i++) {
				adj.add(new ArrayList<>());
			}
			
			for(int i = 2; i <= N; i++) {
				int x = sc.nextInt();
				adj.get(x).add(i);
			}
			nodeStartStop = new int[N+1][2];
			numChildren = new int[N+1];
			dfs(1);

//			for(int[] each: nodeStartStop) {
//				System.out.println(Arrays.toString(each));
//			}
//			System.out.println(Arrays.toString(numChildren));

			segtree = new LazyProp(N);
			switches = new int[N+1];
			for(int i = 1; i <= N; i++) {
				switches[i] = sc.nextInt();
				if(switches[i] == 1) {
					segtree.build(0, 1, N,nodeStartStop[i][0]);
				}
			}			
			//System.out.println(segtree);

			//queries
			int q = sc.nextInt();
			for(int Q = 0; Q < q; Q++) {
				if(sc.next().equals("get")) { // query
					int X = sc.nextInt();
					out.println(segtree.query(nodeStartStop[X][0], nodeStartStop[X][1]-1));
				} else { // update
					int X = sc.nextInt();
					segtree.update(nodeStartStop[X][0], nodeStartStop[X][1]-1, 1);
					//System.out.println(segtree);
				}
			}
			
		}
		
		static LazyProp segtree;
		static int[] numChildren;
		
		static class LazyProp {
			
			int[] t;
			int[] lazy;
	        int N;
	        
	        public LazyProp(int n) {
	            t = new int[4*n];
	            lazy = new int[4*n];
	            N = n;
	        }
	        
	        public void push(int v, int L, int R) {
	        	if(lazy[v] == 0)
	        		return;
	        	// calculate sum of current node based on lazy
	        	t[v] = (R - L + 1) - t[v];
	        	
	        	// propogate to children
	        	if(L < R) {
	        		lazy[2*v+1] ^= lazy[v];
	        		lazy[2*v+2] ^= lazy[v];
	        	}
	        	
	        	// reset this node
	        	lazy[v] = 0;
	        }
	        
	        public void build(int v, int tL, int tR, int node) {
	        	if(node <= tL && tR <= node) {
	        		t[v]++;
	        	} else {
	        		int tM = (tL + tR) / 2;
	        		if(node <= tM) {
	        			build(2 * v + 1, tL, tM, node);
	        		}
	        		if(node >= tM + 1) {
	        			build(2 * v + 2, tM + 1, tR, node);
	        		}
	        		t[v] = t[2 * v + 1] + t[2 * v + 2];
	        	}
	        }
	        
	        public void update(int L, int R, int add) {
	        	update(0, 1, N, L, R, add);
	        }
	        
	        public void update(int v, int tL, int tR, int L, int R, int add) {
	        	push(v, tL, tR);
	        	if(L <= tL && tR <= R) {
	        		lazy[v] += add;
	        	} else {
	        		int tM = (tL + tR) / 2;
	        		if(L <= tM) {
	        			update(2 * v + 1, tL, tM, L, R, add);
	        		}
	        		if(R >= tM + 1) {
	        			update(2 * v + 2, tM + 1, tR, L, R, add);
	        		}
	        		
	        		push(2 * v + 1, tL, tM);
	        		push(2 * v + 2, tM + 1, tR);
	        		t[v] = t[2 * v + 1] + t[2 * v + 2];
	        	}
	        }
	        
	        public int query(int L, int R) {
	        	return query(0, 1, N, L, R);
	        }
	        
	        public int query(int v, int tL, int tR, int L, int R) {
	        	push(v, tL, tR);
	        	if(L <= tL && tR <= R) {
	        		return t[v];
	        	}
	        	int sum = 0;
	        	int tM = (tL + tR) / 2;
	        	if(L <= tM) {
	        		sum += query(2 * v + 1, tL, tM, L, R);
	        	}
	        	if(R >= tM + 1) {
	        		sum += query(2 * v + 2, tM+1, tR, L, R);
	        	}
	        	return sum;
	        }
			
	        public String toString() {
	        	return Arrays.toString(t) + " " + Arrays.toString(lazy);
	        }
		}
		
		static int[][] nodeStartStop;
		static int ID = 1;
		
		public static int dfs(int node) {
			nodeStartStop[node][0] = ID++;
			int sum = 1;
			for(int each: adj.get(node)) {
				sum += dfs(each);
			}
			numChildren[node] = sum;
			nodeStartStop[node][1] = ID;
			return sum;
		}
		
	}
	static long binpow(long a, long b, long m) {
		a %= m;
		long res = 1;
		while (b > 0) {
			if ((b & 1) == 1)
				res = res * a % m;
			a = a * a % m;
			b >>= 1;
		}
		return res;
	}
	static void sort(int[] x){
		shuffle(x);
		Arrays.sort(x);
	}
	static void sort(long[] x){
		shuffle(x);
		Arrays.sort(x);
	}
	static class tup implements Comparable<tup>, Comparator<tup>{
		int a, b;
		tup(int a,int b){
			this.a=a;
			this.b=b;
		}
		public tup() {
		}
		@Override
		public int compareTo(tup o){
			return Integer.compare(b,o.b);
		}
		@Override
		public int compare(tup o1, tup o2) {
			return Integer.compare(o1.b, o2.b);
		}
		
		@Override
	    public int hashCode() {
			return Objects.hash(a, b);
	    }
 
	    @Override
	    public boolean equals(Object obj) {
	    	if (this == obj)
                return true;
	    	if (obj == null)
                return false;
	    	if (getClass() != obj.getClass())
                return false;
	    	tup other = (tup) obj;
	    	return a==other.a && b==other.b;
	    }
	    
	    @Override
	    public String toString() {
	    	return a + " " + b;
	    }
	}
	
	static void shuffle(int[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			int temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}

	static void shuffle(long[] a) {
		Random get = new Random();
		for (int i = 0; i < a.length; i++) {
			int r = get.nextInt(a.length);
			long temp = a[i];
			a[i] = a[r];
			a[r] = temp;
		}
	}

	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

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

		public FastReader(String s) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(new File(s)));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				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;
		}
	}

}