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.*;

public class B {
	FastScanner in = new FastScanner(System.in);
	PrintWriter out = new PrintWriter(System.out);
	
	int MOD = (int)(1e9 + 7);
	
	Integer[][] g;
	int[] p, color;
	long[][] dp;
	
	Integer[][] parseSparseGraph(int[] src, int[] dst, int size) {
		Integer[][] res = new Integer[size][];
		
		@SuppressWarnings("unchecked")
		ArrayList<Integer>[] in_edge = new ArrayList[size];
		for (int i = 0; i < in_edge.length; i++) {
			in_edge[i] = new ArrayList<Integer>();
		}
		
		for (int i = 0; i < src.length; i++) {
			in_edge[src[i]].add(dst[i]);
			in_edge[dst[i]].add(src[i]);
		}

		for (int i = 0; i < size; i++) {
			res[i] = in_edge[i].toArray(new Integer[0]);
		}
		
		return res;
	}
	
	void dfs(int u, int prev) {
		for (int v : g[u]) {
			if (v != prev)
				dfs(v, u);
		}

		long[] now = new long[2];
		
		now[color[u]] = 1;
		for (int v : g[u]) {
			if (v == prev) continue;
			
			long[] ch = dp[v];
			long[] temp = new long[2];
			for (int a = 0; a < 2; a++) {
				for (int b = 0; b < 2; b++) {
					if (a + b < 2) 
						temp[a+b] = (temp[a+b] + now[a] * ch[b]) % MOD;
					if (b == 1)
						temp[a] = (temp[a] + now[a] * ch[b]) % MOD;
				}
			}
			now = temp;
		}
		
		dp[u] = now;
		
//		System.out.println(u + " " + Arrays.toString(dp[u]));
	}
	
	public void run() {
		int n = in.nextInt();
		int[] src = new int[n-1], dst = new int[n-1];
		
		p = new int[n-1];
		color = new int[n];
		dp = new long[n][2];
		
		for (int i = 0; i < n - 1; i++) {
			src[i] = i + 1;
			dst[i] = in.nextInt();
			p[i] = dst[i];
		}
		
		g = parseSparseGraph(src, dst, n);
		
		for (int i = 0; i < n; i++) {
			color[i] = in.nextInt();
		}
		
		dfs(0, -1);
		
		System.out.println(dp[0][1]);
		
		out.close();
	}

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

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");

		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}

		System.out.println("----------------------------");
		System.out.println();
	}

	public void debug(Object... obj) {
		System.out.println(Arrays.deepToString(obj));
	}

	class FastScanner {
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public FastScanner(InputStream stream) {
			this.stream = stream;
			//stream = new FileInputStream(new File("dec.in"));

		}

		int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = stream.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

