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.math.*;
import java.lang.*;
 
import static java.lang.Math.*;
 
public class Main implements Runnable
{
	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;
		private BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}
		
		public int read()
		{
			if (numChars==-1) 
				throw new InputMismatchException();
			
			if (curChar >= numChars)
			{
				curChar = 0;
				try 
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}
				
				if(numChars <= 0)				
					return -1;
			}
			return buf[curChar++];
		}
	 
		public String nextLine()
		{
			String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
		}
		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 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 double nextDouble() 
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') 
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.') 
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.') 
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c)) 
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}
		
		public String readString() 
		{
			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 boolean isSpaceChar(int c) 
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}
	 
		public String next() 
		{
			return readString();
		}
		
		public interface SpaceCharFilter 
		{
			public boolean isSpaceChar(int ch);
		}
	}
 	
	public static void main(String args[]) throws Exception
	{
		new Thread(null, new Main(),"Main",1<<26).start();
	}
    void updateSegTree(int low, int high, int pos, int l, int r)
    {
        if(low >= l  && high <= r)
        {
            if(lazy[pos] == 0)
            {
                segTree[pos] = (high - low + 1) - segTree[pos];
                if(low != high)
                {
                    lazy[2 * pos + 1] ^= 1;
                    lazy[2 * pos + 2] ^= 1;
                }
            }
            else
                lazy[pos] = 0;
            return;
        }
        if(low > r || high < l)
        {
            if(lazy[pos] == 1)
            {
                lazy[pos] = 0;
                segTree[pos] = (high - low + 1) - segTree[pos];
                if(low != high)
                {
                    lazy[2 * pos + 1] ^= 1;
                    lazy[2 * pos + 2] ^= 1;
                }
            }
            return;        
        }
        int mid = (low + high) >> 1;
        if(lazy[pos] == 1)
        {
            lazy[pos] = 0;
            lazy[2 * pos + 1] ^= 1;
            lazy[2 * pos + 2] ^= 1;
        }
        updateSegTree(low, mid, 2 * pos + 1, l, r);
        updateSegTree(mid + 1, high, 2 * pos + 2, l, r);
        segTree[pos] = segTree[2 * pos + 1] + segTree[2 * pos + 2];
    }
    
    void printSegTree(int low, int high, int pos)
    {   
        if(low == high)
        {
            System.out.println(low + " " + high + " " + segTree[pos] + " " + lazy[pos]);
            return;
        }
        int mid = (low + high) >> 1;
        printSegTree(low, mid, 2 * pos + 1);
        printSegTree(mid + 1, high, 2 * pos + 2);
        System.out.println(low + " " + high + " " + segTree[pos] + " " + lazy[pos]);
    }
    
    int querySegTree(int low, int high, int pos, int l, int r)
    {   
        if(low >= l && high <= r)
        {   
            if(lazy[pos] == 1)
            {
                segTree[pos] = (high - low + 1) - segTree[pos];
                if(low != high)
                {
                    lazy[2 * pos + 1] ^= 1;
                    lazy[2 * pos + 2] ^= 1;
                }
                lazy[pos] = 0;
            }
            return segTree[pos];
        }
        if(low > r || high < l)
        {
            if(lazy[pos] == 1)
            {
                lazy[pos] = 0;
                segTree[pos] = (high - low + 1) - segTree[pos];
                if(low != high)
                {
                    lazy[2 * pos + 1] ^= 1;
                    lazy[2 * pos + 2] ^= 1;
                }
            }
            return 0;
        }
        int mid = (low + high) >> 1;
        if(lazy[pos] == 1)
        {
            lazy[pos] = 0;
            lazy[2 * pos + 1] ^= 1;
            lazy[2 * pos + 2] ^= 1;
        }
        int val1 = querySegTree(low, mid, 2 * pos + 1, l, r);
        int val2 = querySegTree(mid + 1, high, 2 * pos + 2, l, r);
        segTree[pos] = segTree[2 * pos + 1] + segTree[2 * pos + 2];
        return val1 + val2;
    }
    
    void dfs(int i)
    {
        occ[i] = cur;
        eulerTour[cur++] = i;
        for(int j : adj[i])
            dfs(j);
        lastocc[i] = cur - 1;
    }
    
    int cur = 0;
    ArrayList<Integer> adj[];
    int occ[], lastocc[], eulerTour[];
    int segTree[], lazy[];
    
	public void run()
	{
		InputReader sc = new InputReader(System.in);
		PrintWriter w = new PrintWriter(System.out);
        
        int n = sc.nextInt();
		
        adj = new ArrayList[n];
        for(int i = 0; i < n; ++i)
            adj[i] = new ArrayList<>();
        
        occ = new int[n];
        lastocc = new int[n];
        eulerTour = new int[n];
        
        for(int i = 1; i < n; ++i)
        {
            int u = sc.nextInt() - 1;
            adj[u].add(i);
        }
        
        dfs(0);
        
        segTree = new int[4 * n];
        lazy = new int[4 * n];
        
        for(int i = 0; i < n; ++i)
        {
            if(sc.nextInt() == 1)
                updateSegTree(0, n - 1, 0, occ[i], occ[i]);
        }
        
        //printSegTree(0, n - 1, 0);
        
        int q = sc.nextInt();
        
        for(int x = 0; x < q; ++x)
        {
            String type = sc.next();
            if(type.equals("get"))
            {
                int u = sc.nextInt() - 1;
                w.println(querySegTree(0, n - 1, 0, occ[u], lastocc[u]));
            }
            else
            {
                int u = sc.nextInt() - 1;
                updateSegTree(0, n - 1, 0, occ[u], lastocc[u]);
                //printSegTree(0, n - 1, 0);
            }
        }
        
		w.close();
	}
}