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.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
import java.util.Arrays;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class MainC {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskA solver = new TaskA();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskA {
    public void dfs(long[][] dp, ArrayList<Integer>[] tree, int[] colors, int v, int MOD) {
	if (colors[v] == 1) {
		dp[v][0] = 0; 
		dp[v][1] = 1; 
	} else {
		dp[v][0] = 1; 
		dp[v][1] = 0; 
	}
	if (tree[v] == null) return;

	for (int u : tree[v]) {
		dfs(dp, tree, colors, u, MOD);
		if (colors[v] == 1) {
			dp[v][1] *= (dp[u][0] + dp[u][1]) % MOD;
			dp[v][1] = dp[v][1] % MOD;
		} else {
			// Assume that dp[v][1] stores the num solutions if there 
			// is a single black node in the children from 1-(u-1).

			// First suppose the black node does not come from u. 
			// Then it must be between 1-(u-1). 
			// So multiply dp[v][1], which stores that, by dp[u][0], 
			// which is the number of ways to arrange arrange the whites in u.

			// Now suppose that the black node does come from u.
			// How many ways are there to get the black node? This is just dp[u][1] but we must also
			// multiply it by the number of ways to ensure all children from 1 - (u-1) are white. 
			// This value is stored for us in dp[v][0].
			dp[v][1] *= (dp[u][0] + dp[u][1]) % MOD;
			dp[v][1] = dp[v][1] % MOD;
			dp[v][1] += (dp[v][0] * dp[u][1]) % MOD;
			dp[v][1] = dp[v][1] % MOD;

			// Assume that dp[v][0] stores the num solutions if there is are 
			// no black nodes in children from 1-(u-1).
			// Then for the next child, there continue to be no children. 
			// If u is connected to v, there are dp[u][0] ways. 
			// If u is not connected to v, there are dp[u][1] ways. 
			// You add these together (the total number of ways) 
			// and multiply by the already-existing combinations.
			dp[v][0] *= (dp[u][0] + dp[u][1]) % MOD;
			dp[v][0] = dp[v][0] % MOD;
		}

	}

    }
    public void solve(int testNumber, InputReader in, PrintWriter out) {
    	int MOD = (int) 1e9 + 7;
	int n = in.nextInt();
	ArrayList<Integer>[] tree = (ArrayList<Integer>[]) new ArrayList[n]; 
	int[] colors = new int[n];
	for (int i = 0; i < n - 1; i++) {
		int parent = in.nextInt();
		if (tree[parent] == null) {
			tree[parent] = new ArrayList<Integer>();
		}
		tree[parent].add(i + 1);
	}

	for (int i = 0; i < colors.length; i++) {
		colors[i] = in.nextInt();
	}

	long[][] dp = new long[n][2];
	dfs(dp, tree, colors, 0, MOD);
	out.write((dp[0][1] % MOD) + "\n");
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(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 nextInt() {
        return Integer.parseInt(next());
    }

}