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.util.ArrayList;
import java.util.InputMismatchException;
import java.math.BigInteger;
import java.io.*;
import java.util.*;

/**
 * Generated by Contest helper plug-in
 * Actual solution is at the bottom
 */

public class Main {
	public static void main(String[] args) {
		InputReader in = new StreamInputReader(System.in);
		PrintWriter out = new PrintWriter(System.out);
		run(in, out);
	}

	public static void run(InputReader in, PrintWriter out) {
		Solver solver = new Task();
		solver.solve(1, in, out);
		Exit.exit(in, out);
	}
}

abstract class InputReader {
	private boolean finished = false;

	public abstract int read();

	public long readLong() {
		return new BigInteger(readString()).longValue();
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

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

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

	public void setFinished(boolean finished) {
		this.finished = finished;
	}

	public abstract void close();
}

class StreamInputReader extends InputReader {
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar, numChars;

	public StreamInputReader(InputStream stream) {
		this.stream = stream;
	}

	public 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++];
	}

	public void close() {
		try {
			stream.close();
		} catch (IOException ignored) {
		}
	}
}

class Exit {
	private Exit() {
	}

	public static void exit(InputReader in, PrintWriter out) {
		in.setFinished(true);
		in.close();
		out.close();
	}
}

interface Solver {
	public void solve(int testNumber, InputReader in, PrintWriter out);
}

class Task implements Solver {
	public void solve(int testNumber, InputReader in, PrintWriter out) {
		
		int n = in.readInt();
		int[] e = new int[n-1];
		for (int i = 0; i<n-1; i++)
			e[i] = in.readInt();
		boolean[] b = new boolean[n];
		for (int i = 0; i<n; i++)
			if (in.readInt() == 1)
				b[i] = true;
		
		ArrayList<ArrayList<Integer>> children = new ArrayList<ArrayList<Integer>>();
		
		for (int i = 0; i<n; i++) {
			children.add(new ArrayList<Integer>());
		}
		
		for (int i = 0; i<n-1; i++) {
			children.get(e[i]).add(i+1);
		}
		
		long[][] dp = new long[n][2];
		
		run(0, dp, children, b);
		
		System.out.println(dp[0][1]%1000000007);
	}

	private void run(int v, long[][] dp, ArrayList<ArrayList<Integer>> children, boolean[] b) {
		
		dp[v][0] = 1;
		dp[v][1] = 0;
		
		long white = 1;
		long black = 0;
		
		for (int u : children.get(v)) {
			run(u, dp, children, b);
			black *= dp[u][0];
			black += white * dp[u][1];
			white *= dp[u][0];
			
			black%=1000000007;
			white%=1000000007;
		}
		
		dp[v][0] = white;
		dp[v][1] = black;
		
		if (b[v]) {
			black = white;
		} else {
			white += black;
		}
	
		dp[v][0] = white;
		dp[v][1] = black;
		
	}

	
}

///

