Appleman has a tree with n vertices. Some of the vertices (at least one) are colored black and other vertices are colored white.

Consider a set consisting of k (0 ≤ k < n) edges of Appleman's tree. If Appleman deletes these edges from the tree, then it will split into (k + 1) parts. Note, that each part will be a tree with colored vertices.

Now Appleman wonders, what is the number of sets splitting the tree in such a way that each resulting part will have exactly one black vertex? Find this number modulo 1000000007 (109 + 7).

Input

The first line contains an integer n (2 ≤ n ≤ 105) — the number of tree vertices. 

The second line contains the description of the tree: n - 1 integers p0, p1, ..., pn - 2 (0 ≤ pi ≤ i). Where pi means that there is an edge connecting vertex (i + 1) of the tree and vertex pi. Consider tree vertices are numbered from 0 to n - 1.

The third line contains the description of the colors of the vertices: n integers x0, x1, ..., xn - 1 (xi is either 0 or 1). If xi is equal to 1, vertex i is colored black. Otherwise, vertex i is colored white.

Output

Output a single integer — the number of ways to split the tree modulo 1000000007 (109 + 7).

Examples

Input

3
0 0
0 1 1


Output

2


Input

6
0 1 1 0 4
1 1 0 0 1 0


Output

1


Input

10
0 1 2 1 4 4 4 0 8
0 0 0 1 0 1 1 0 0 1


Output

27
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;


public class AppleManAndTree {



	static long DP[][] = new long[100000+5][2];
	static int MOD = 1000 * 1000 * 1000 + 7;
	static IR in = new IR(System.in);
	static boolean isBlack[] = new boolean[100000+5];
	static ArrayList<Integer> tree[] = new ArrayList[100000+5];
	static int N,E;
	static PrintWriter out = new PrintWriter(System.out);

	static long inv(long x){
		if(x == 0) x += MOD;
		long M = MOD;
		long r,y;
		for(r=1,y=M-2; y > 0 ;x=x*x%M,y>>=1) 
			if((y&1) == 1) r= (r*x%M);
		return r;
	}

	public static long solve(int idx,int flag,int p)
	{

		int childs = 0;
		long ways = 1;

		
		if(DP[idx][flag] != -1) return DP[idx][flag];
		if(isBlack[idx])
		{
			// current vertex is black
			// both cases of flag do not matter.
			// either ways I must try to color subtrees below me, and cut/keep that edge.
			for(Integer k : tree[idx])
			{
				if(k == p) continue;
				ways *= solve(k,1,idx);
				ways %= MOD;
				++childs;
			}


		}
		else
		{
			long sum = 1;
			ways = 0;
			if(flag == 0)
			{
				// must keep edge with parent
				for(Integer k : tree[idx])
				{
					if(k == p) continue;
					sum *= solve(k,1,idx);
					sum %= MOD;
					++childs;
				}
				for(Integer k : tree[idx])
				{
					// make this ingoing subtree black through only one of it's children
					if(k == p) continue;
					ways += ((sum * inv(solve(k,1,idx)))%MOD ) * (solve(k,0,idx)%MOD);
				
				}
			}
			else
			{
				// disconnect upward edge with parent
				for(Integer k : tree[idx])
				{
					if(k == p) continue;
					sum *= solve(k,1,idx);
					sum %= MOD;
					++childs;
				}
				for(Integer k : tree[idx])
				{
					// make this ingoing subtree black through only one of it's children
					if(k == p) continue;
					ways += ( (sum * inv(solve(k,1,idx)) ) %MOD) * (solve(k,0,idx) % MOD);
					ways %= MOD;
				
				}
				
				// keep upward edge with parent
				long nways = 1;
				for(Integer k : tree[idx])
				{
					if(k == p) continue;
					nways *= solve(k,1,idx);
					nways %= MOD;
					
				}
				ways += nways;
				ways %= MOD;
				
			}
		}

		
		if(childs == 0) return !isBlack[idx] && flag == 0? 0 : 1;
		else return DP[idx][flag] = ways;
	}


	public static void main(String[]args)throws Throwable
	{

		N = in.j();
		E = N - 1;
		int v;
		for(int i = 0 ; i < N ; i++) tree[i] = new ArrayList();
		for(int i = 0 ; i < E ; i++)
		{
			v = in.j(); 
			tree[i + 1].add(v);
			tree[v].add(i + 1);
		}

		int col;
		for(int i = 0 ; i < 100000+ 5 ; i++)
			for(int j = 0 ; j < 2 ; j++)
				DP[i][j] = -1;
		for(int i = 0 ; i < N ; i++)
		{
			col = in.j();;
			isBlack[i] = (col == 1);
		}
		out.printf("%d",solve(0,0, - 1) % MOD);
		out.flush();
		out.close();

	}

	static	class IR {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public IR(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int j() {
			return Integer.parseInt(next());
		}
		public long ll(){
			return Long.parseLong(next());
		}


	}


}
