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.*;
import java.util.*;
import java.lang.*;
import java.math.*;

import static java.lang.Math.*;

public class Solution implements Runnable {
	
	final int MOD = (int)(1e9) + 7;
	
	ArrayList<Integer> g[];
	int dp[][];
	int color[];
	
	void doIt(int v) {
		dp[v][0] = 1;
		dp[v][1] = 0;
		for (int i = 0; i < g[v].size(); i++) {
			int to = g[v].get(i);
			doIt(to);
			dp[v][1] = (int)(dp[v][1] * 1L * dp[to][0] % MOD);
			dp[v][1] = (int)((dp[v][1] + (dp[v][0] * 1L * dp[to][1] % MOD)) % MOD);
			dp[v][0] = (int)(dp[v][0] * 1L * dp[to][0] % MOD);
		}
		if (color[v] == 1)
			dp[v][1] = dp[v][0];
		else
			dp[v][0] += dp[v][1];
	}
	
	void solve() throws Exception {
		int n = sc.nextInt();
		g = new ArrayList[n];
		dp = new int[n][2];
		for (int i = 0; i < n; i++) {
			g[i] = new ArrayList<Integer>();
		}
		color = new int[n];
		for (int i = 1; i < n; i++) {
			g[sc.nextInt()].add(i);
		}
		for (int i = 0; i < n; i++) {
			color[i] = sc.nextInt();
		}
		doIt(0);
		out.println(dp[0][1]);		
	}
	
	BufferedReader in;
	PrintWriter out;
	FastScanner sc;
	
	static Throwable throwable;
	
	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			//in = new BufferedReader(new FileReader(".in"));
			//out = new PrintWriter(".out");
			sc = new FastScanner(in);
			solve();
		} catch (Exception e) {
			throwable = e;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread thread = new Thread(null, new Solution(), "", (1 << 26));
		thread.start();
		thread.join();
		thread.run();
		if (Solution.throwable != null)
			throw Solution.throwable;
	}

}

class FastScanner {
	BufferedReader reader;
	StringTokenizer strTok;
	
	public FastScanner(BufferedReader reader) {
		this.reader = reader;
	}
	
	public String nextToken() throws Exception {
		while (strTok == null || !strTok.hasMoreTokens())
			strTok = new StringTokenizer(reader.readLine());
		return strTok.nextToken();
	}
	
	public int nextInt() throws Exception {
		return Integer.parseInt(nextToken());
	}
	
	public long nextLong() throws Exception {
		return Long.parseLong(nextToken());
	}
	
	public double nextDouble() throws Exception {
		return Double.parseDouble(nextToken());
	}
}