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.Arrays;
import java.util.StringTokenizer;

public class C263D {
	FastScanner in;
	PrintWriter out;
	BufferedReader bf;
	final int MOD = (int) 1e9 + 7;

	public class node {
		int id;
		long dp0;
		long dp1;
		int color;
		boolean visited;
		ArrayList<Integer> edges;

		public node(int i) {
			id = i;
			dp0 = -1;
			dp1 = -1;
			color = 0;
			visited = false;
			edges = new ArrayList<Integer>();
		}

	}

	class FastScanner {
		public node[] nodes;
		public long[][] dp;

		public long rec(int s, int p, int c) {
			// System.out.println("id: " + s + " req: " + c + " at C: "
			// + nodes[s].color);

			if (nodes[s].visited) {
				return c == 0 ? nodes[s].dp0 : nodes[s].dp1;
			}
			nodes[s].visited = true;
			long dp1 = 0;
			long dp0 = 0;
			if (nodes[s].color == 0) {
				dp1 = 0;
				dp0 = 1;
				for (int x : nodes[s].edges) {
					dp1 *= (rec(x, s, 0) + rec(x, s, 1));
					dp1 %= MOD;
					dp1 += (dp0 * rec(x, s, 1));
					dp1 %= MOD;
					dp0 *= (rec(x, s, 1) + rec(x, s, 0));
					dp0 %= MOD;
				}

			} else {
				dp1 = 1;
				dp0 = 0;
				for (int x : nodes[s].edges) {

					dp1 *= (rec(x, s, 0) + rec(x, s, 1));
					dp1 %= MOD;

				}
			}

			nodes[s].dp0 = dp0;
			nodes[s].dp1 = dp1;
			// System.out.println("   " + nodes[s].dp0 + " " + nodes[s].dp1);
			return c == 0 ? nodes[s].dp0 : nodes[s].dp1;
		}

		public void Solve() {
			int n = ni();
			nodes = new node[n];

			for (int i = 0; i < n; i++)
				nodes[i] = new node(i);

			for (int i = 0; i < n - 1; i++) {
				int a = ni();
				int b = i + 1;
				nodes[a].edges.add(b);

			}
			for (int i = 0; i < n; i++) {
				int c = ni();
				nodes[i].color = c;
			}
			long res = 0;
			res = rec(0, -1, 1);
			System.out.println(res);

		}

		BufferedReader br;
		StringTokenizer st;

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String n() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		String l() {
			String s = null;
			try {
				s = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return s;

		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

		int nb() {
			return Integer.parseInt(n(), 2);
		}

		long nbl() {
			return Long.parseLong(n(), 2);
		}

		int ni() {
			return Integer.parseInt(n());
		}

		double nd() {
			return Double.parseDouble(n());
		}

		long nl() {
			return Long.parseLong(n());
		}
	}

	public void run() {
		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);
		in.Solve();
		out.close();
	}

	public static void main(String[] args) {
		new C263D().run();
	}
}