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


public class R263qBApplemanAndTree {

	static int n;
	static ArrayList<Integer> g[];
	static long dp[][];
	static int x[];
	static final int mod = (int)(1e9 + 7);
	
	@SuppressWarnings("unchecked")
	public static void main(String args[] ) throws Exception {
		   
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    PrintWriter w = new PrintWriter(System.out);
	    
	    n = ip(br.readLine());
		
	    g = new ArrayList[n];
	    for(int i=0;i<n;i++)
			g[i] = new ArrayList<Integer>();
		
	    StringTokenizer st1 = new StringTokenizer(br.readLine()); 
		for(int i=1;i<n;i++)
			g[ip(st1.nextToken())].add(i);
	    
		x = new int[n];
		StringTokenizer st2 = new StringTokenizer(br.readLine());
		for(int i=0;i<n;i++)
			x[i] = ip(st2.nextToken());
		
		dp = new long[n][2];
		for(int i=0;i<n;i++)	dp[i][0] = dp[i][1] = -1; //dp[i][j] = ans for subtree[i] with j needed
		
		w.println(solve(0,1));
		w.close(); 
	}
	
	public static long solve(int curr,int state){
		//System.out.println(curr + " " + state);
		if(dp[curr][state] == -1){
			
			long ans = 0;
			if(state == 1){ //if 1 needed
				if(x[curr] == 0){
					long temp = 1;
					for(int next : g[curr])
						temp = (temp * (solve(next,1) + solve(next,0))) % mod;
					for(int next : g[curr]){
						long temp2 = (temp * inv(solve(next,0) + solve(next,1))) % mod;
						temp2 = (temp2 * solve(next,1)) % mod;
						ans += temp2;
						if(ans >= mod)
							ans -= mod;
					}
				}
				else{
					ans = 1;
					for(int next : g[curr])
						ans = (ans * (solve(next,0) + solve(next,1))) % mod;
				}
			}
			
			else{
				if(x[curr] == 0){
					ans = 1;
					for(int next : g[curr])
						ans = (ans * (solve(next,1) + solve(next,0))) % mod;
				}
				else
					ans = 0;
			}
			
			dp[curr][state] = ans;
			//System.out.println(curr + " " + state + " " + dp[curr][state] + " " + g[curr]);
		}
		
		return dp[curr][state];
	}
	
	public static long inv(long x){
		return pow((int)(x%mod),mod-2);
	}
	
	public static long pow(int a,int b){
		if(b == 0)
			return 1;
		long t = pow(a,b>>1);
		t = (t * t) % mod;
		if( (b & 1) != 0)
			t = (t * a) % mod;
		return t;
	}
	
	public static int ip(String s){
		return Integer.parseInt(s);
	}
}
