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.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
import java.util.StringTokenizer;

public class CF263_Tree {

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

	public void run() {

		// Read input
		MyScanner in = new MyScanner();
		int nVerts = in.nextInt();

		Node[] verts = new Node[nVerts];
		for (int i = 0; i < nVerts; i++) {
			verts[i] = new Node();
		}

		for (int i = 0; i < (nVerts - 1); i++) {
			int to = in.nextInt();
			verts[i + 1].adj.add(verts[to]);
			verts[to].adj.add(verts[i + 1]);
		}

		Node root = null;
		for (int i = 0; i < nVerts; i++) {
			int color = in.nextInt();
			if (color == 1) {
				verts[i].black = true;
				root = verts[i];
			}
		}

		// If there are no black nodes there's not way to split
		if (root == null) {
			System.out.println(0);
			return;
		}

		ArrayList<Node> initLeaves = new ArrayList<Node>();

		Queue<Node> readyNodes = new LinkedList<Node>();

		// Root the tree
		Queue<Node> toProc = new LinkedList<Node>();
		toProc.add(root);
		while (!toProc.isEmpty()) {
			Node n = toProc.poll();
			for (int i = 0; i < n.adj.size(); i++) {
				Node c = n.adj.get(i);
				if (c.parent == null && c != root) {
					n.children.add(c);
					c.parent = n;
					toProc.add(c);
				}
			}

			n.unreadyChildren = n.children.size();

			if (n.children.isEmpty()) {
				readyNodes.add(n);
			}
		}

		// Solve the main problem
		while (!readyNodes.isEmpty()) {

			Node n = readyNodes.poll();

			// Leaves
			if (n.children.size() == 0) {
				if(n.black) {
					n.H = 1;
					n.N = 0;
				}else {
					n.N = 1;
					n.H = 0;
				}
			}

			// Nodes with n >= 1 children
			else {
		
				long nhProd = 1;
				for (int i = 0; i < n.children.size(); i++) {
					Node c = n.children.get(i);
					nhProd = MOD(nhProd * MOD(c.H + c.N));
				}
				
				if(n.black) {
					n.N = 0;
					n.H = nhProd;
				} else {
					
					n.N = nhProd;
					
					// Expensive calculation for the sum
					long[] hArr = new long[n.children.size()];
					long[] nArr = new long[n.children.size()];
					for (int i = 0; i < n.children.size(); i++) {
						Node c = n.children.get(i);
						hArr[i] = c.H;	
						nArr[i] = c.N;
					}
					
					n.H = evalSum(hArr, nArr);
				}
				
			}

			// Possibly process the parent
			if (n == root) {
				continue;
			}
			n.parent.unreadyChildren--;
			if (n.parent.unreadyChildren == 0) {
				readyNodes.add(n.parent);
			}
		}
		
		
		System.out.println(root.H);

	}
	
	public static long evalSum(long[] hVals, long[] nVals) {
		
		if(hVals.length == 1) {
			return hVals[0];
		}
		
		long[] leftMult = new long[hVals.length];
		long[] rightMult = new long[hVals.length];
		
		leftMult[0] = 1;
		for(int i = 0; i < hVals.length-1; i++) {
			leftMult[i+1] = MOD(leftMult[i]*(nVals[i]+hVals[i]));
		}
		rightMult[hVals.length-1] = 1;
		for(int i = hVals.length-1; i > 0; i--) {
			rightMult[i-1] = MOD(rightMult[i]*(nVals[i]+hVals[i])); 
		}
		
		long sumVal = 0;
		for(int i = 0; i < hVals.length; i++) {
			sumVal = MOD(sumVal + MOD(hVals[i] * MOD(leftMult[i] * rightMult[i])));
		}
		
		return sumVal;
	}

	static final long MODNUM = 1000000007;

	public static long MOD(long x) {
		return x % MODNUM;
	}

	public class Node {

		ArrayList<Node> adj = new ArrayList<Node>();
		ArrayList<Node> children = new ArrayList<Node>();
		Node parent = null;
		boolean black = false;

		int unreadyChildren = -1;

		long H = -1;
		long N = -1;

	}

	public static class MyScanner {
		BufferedReader br;
		StringTokenizer st;

		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

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

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

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

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

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}

	}

}
