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.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.StringTokenizer;

/*
public class _461B {

}

 */

public class _461B {

	int mod = (int)1e9 + 7;
	public void solve() throws FileNotFoundException {
		InputStream inputStream = System.in;

		InputHelper inputHelper = new InputHelper(inputStream);

		PrintStream out = System.out;

		//actual solution
		int n =inputHelper.readInteger();

		List[] g = new List[n];

		for(int i = 0; i < n - 1; i ++)
		{
			int v = inputHelper.readInteger();

			if(g[v] == null)
			{
				g[v] = new ArrayList<Integer>();
			}

			g[v].add(i + 1);
		}

		c = new int[n];

		for(int i  = 0; i < n; i++)
		{
			c[i] = inputHelper.readInteger();
		}

		cb = new int[n];
		dfs(0, g);

		if(cb[0] == 0)
		{
			System.out.println("0");
			return;
		}
		else if(cb[0] == 1)
		{
			System.out.println("1");
			return;
		}

		dp = new long[n][2];
		dfs2(0, g);

		System.out.println(dp[0][1]);
		//end here
	}

	long[][] dp;
	List<Integer> al = new ArrayList<Integer>();
	private void dfs2(int u, List[] g) {
		if(g[u] == null)
		{
			if(c[u] == 1)
			{
				dp[u][0] = 0;
				dp[u][1] = 1;
			}
			else
			{
				dp[u][0] = 1;
				dp[u][1] = 0;
			}
			return;
		}

		if(c[u] == 0)
		{
			dp[u][0] = 1;
			dp[u][1] = 0;
			for(int i = 0; i < g[u].size(); i++)
			{
				int v = (Integer)g[u].get(i);
				dfs2(v, g);
				dp[u][0] *= (dp[v][0] + dp[v][1]);
				dp[u][0] %= mod;
			}

			long[] tempf = new long[g[u].size()];
			long[] tempb = new long[g[u].size()];
			
			tempf[0] = (dp[(Integer)g[u].get(0)][0] + dp[(Integer)g[u].get(0)][1]) % mod;
			tempb[g[u].size() - 1] = (dp[(Integer)g[u].get(g[u].size() - 1)][0] + dp[(Integer)g[u].get(g[u].size() - 1)][1]) % mod;
			
			for(int i = 1; i < g[u].size(); i++)
			{
				int v = (Integer)g[u].get(i);
				int vb = (Integer)g[u].get(i - 1);
				tempf[i] = tempf[i - 1] * (dp[v][0] + dp[v][1]);
				tempf[i] %= mod;
			}
			for(int i = g[u].size() - 2; i >= 0; i--)
			{
				int v = (Integer)g[u].get(i);
				int vf = (Integer)g[u].get(i + 1);
				tempb[i] = tempb[i + 1] * (dp[v][0] + dp[v][1]);
				tempb[i] %= mod;
			}
			for(int i = 0; i < g[u].size(); i++)
			{
				int v = (Integer)g[u].get(i);
				
				long temp = 1;
				
				if(i > 0)
				{
					int vb = (Integer)g[u].get(i - 1);
					temp *= tempf[i - 1];
					temp %= mod;
				}
				
				temp *= (dp[v][1]);
				temp %= mod;
				
				if(i < g[u].size() - 1)
				{
					int vf = (Integer)g[u].get(i + 1);
					temp *= tempb[i + 1];
					temp %= mod;
				}

				dp[u][1] += temp;
				dp[u][1] %= mod;
			}
		}
		else
		{
			dp[u][1] = 1;
			dp[u][0] = 0;
			for(int i = 0; i < g[u].size(); i++)
			{
				int v = (Integer)g[u].get(i);
				dfs2(v, g);
				dp[u][1] *= (dp[v][0] + dp[v][1]);
				dp[u][1] %= mod;
			}
		}
	}

	int[] c;
	int[] cb;
	private int dfs(int u, List[] g) {

		if(c[u] == 1)
			cb[u] =  1;

		if(g[u] == null || g[u].size() == 0)
			return cb[u];

		for(int i = 0; i < g[u].size(); i++)
		{
			cb[u] += dfs((Integer)g[u].get(i), g);
		}

		return cb[u];
	}

	public static void main(String[] args) throws FileNotFoundException {
		(new _461B()).solve();
	}

	class InputHelper {
		StringTokenizer tokenizer = null;
		private BufferedReader bufferedReader;

		public InputHelper(InputStream inputStream) {
			InputStreamReader inputStreamReader = new InputStreamReader(
					inputStream);
			bufferedReader = new BufferedReader(inputStreamReader, 16384);
		}

		public String read() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					String line = bufferedReader.readLine();
					if (line == null) {
						return null;
					}
					tokenizer = new StringTokenizer(line);
				} catch (IOException e) {
					e.printStackTrace();
				}
			}

			return tokenizer.nextToken();
		}

		public Integer readInteger() {
			return Integer.parseInt(read());
		}

		public Long readLong() {
			return Long.parseLong(read());
		}
	}
}