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.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.PriorityQueue;
import java.util.StringTokenizer;


public class Solution{
	
	///////////////////////////////////////////////////////////////////////////
	static class FastScanner{
		BufferedReader s;
		StringTokenizer st;
		
		public FastScanner(){
			st = new StringTokenizer("");
			s = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public FastScanner(File f) throws FileNotFoundException{
			st = new StringTokenizer("");
			s = new BufferedReader (new FileReader(f));
		}
		
		public int nextInt() throws IOException{
			if(st.hasMoreTokens())
				return Integer.parseInt(st.nextToken());
			else{
				st = new StringTokenizer(s.readLine());
				return nextInt();
			}
		}
		
		public double nextDouble() throws IOException{
			if(st.hasMoreTokens())
				return Double.parseDouble(st.nextToken());
			else{
				st = new StringTokenizer(s.readLine());
				return nextDouble();
			}
		}
		
		public long nextLong() throws IOException{
			if(st.hasMoreTokens())
				return Long.parseLong(st.nextToken());
			else{
				st = new StringTokenizer(s.readLine());
				return nextLong();
			}
		}
		
		public String nextString() throws IOException{
			if(st.hasMoreTokens())
				return st.nextToken();
			else{
				st = new StringTokenizer(s.readLine());
				return nextString();
			}
			
		}
		public String readLine() throws IOException{
			return s.readLine();
		}
		
		public void close() throws IOException{
			s.close();
		}
		
	}
	
	////////////////////////////////////////////////////////////////////
	//		Number Theory
	
	long pow(long a,long b,long mod){
		long x = 1; long y = a;
		while(b > 0){
			if(b % 2 == 1){
				x = (x*y);
				x %= mod;
			}
			y = (y*y);
			y %= mod;
			b /= 2;			
		}
		return x;
	}
	
	public static int divisor(int x){
	    int limit = x;
	    int numberOfDivisors = 0;

	    for (int i=1; i < limit; ++i) {
	        if (x % i == 0) {
	            limit = x / i;
	            if (limit != i) {
	                numberOfDivisors++;
	            }
	            numberOfDivisors++;
	        }
	    }
	    return numberOfDivisors;
    }
	
	void findSubsets(int array[]){
    	
	    long numOfSubsets = 1 << array.length; 
	    for(int i = 0; i < numOfSubsets; i++){
	    		
	    	int pos = array.length - 1;
	    	int bitmask = i;

	 //      System.out.print("{");

	    	while(bitmask > 0){
	    			
	    		if((bitmask & 1) == 1)
//	   				arr[array[pos]]++;
	   			bitmask >>= 1;
	        	pos--;
	    	}
	    		
//	   		ww.println();
	   	}
	}
    
	
	public static int gcd(int a, int b){
		return b == 0 ? a : gcd(b,a%b);
	}
	
  
	public static int lcm(int a,int b, int c){
		return lcm(lcm(a,b),c);
	}
	
	public static int lcm(int a, int b){
		return a*b/gcd(a,b);
	}
	
	
	////////////////////////////////////////////////////////////////////
	
	
//	  private static  	FastScanner s = new FastScanner(new File("input.txt"));
//	  private static PrintWriter ww = new PrintWriter(new FileWriter("output.txt"));
	  private static FastScanner s = new FastScanner();   
      private static PrintWriter ww = new PrintWriter(new OutputStreamWriter(System.out));
//      private static Scanner s = new Scanner(System.in);
	@SuppressWarnings("unused")
	private static int[][] states = { {-1,0} , {1,0} , {0,-1} , {0,1} };
	
      
    //////////////////////////////////////////////////////////////////// 
      
     
    public static void main(String[] args) throws IOException{
 		new Solution().solve();
 	}
    
    ////////////////////////////////////////////////////////////////////
    
    int max = 100005;
    int[] B;
    List<Integer>[] arr;
    long[][] DP;
    int MOD = 1000000007;
  
    void dfs(int n, int p)
    {
        DP[n][1] = B[n];
        DP[n][0] = 1 - B[n];

        for(int v : arr[n]) if(v != p)
        {
            long[] old = new long[2];
            old[0] = DP[n][0];
            old[1] = DP[n][1];

            DP[n][0] = DP[n][1] = 0;

            dfs(v,n);

            // Child v is included

            DP[n][0] += DP[v][0] * old[0];
            DP[n][0] %= MOD;
            DP[n][1] += DP[v][1] * old[0];
            DP[n][1] %= MOD;
            DP[n][1] += DP[v][0] * old[1];
            DP[n][1] %= MOD;

            // Child v is not included

            DP[n][0] += DP[v][1] * old[0];
            DP[n][0] %= MOD;
            DP[n][1] += DP[v][1] * old[1];
            DP[n][1] %= MOD;
        }
    }
    
	@SuppressWarnings("unchecked")
	void solve() throws IOException{
    	
		B = new int[max];
		DP = new long[max][2];
		arr = new List[max];
		for(int i=0;i<max;i++)
			arr[i] = new ArrayList<Integer>();
		
		int n = s.nextInt();
		for(int i=2;i<=n;i++){
			int x = s.nextInt();
			arr[x+1].add(i);
			arr[i].add(x+1);
		}
		
		for(int i=1;i<=n;i++)
			B[i] = s.nextInt();
		
		dfs(1,0);
		ww.println(DP[1][1]);
        s.close();
 	    ww.close(); 
    
     }
    
}