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 Main{
    final boolean isFileIO = false; 
    BufferedReader in;
    PrintWriter out;
    StringTokenizer st = new StringTokenizer("");
    String delim = " ";

    public static void main(String[] args) throws IOException {
        Main m = new Main();
        m.initIO();
        m.solve();
        m.in.close();
        m.out.close();
    }

    public void initIO() throws IOException {
        if(!isFileIO) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt"); 
        }
    }
  
    String nextToken() throws IOException {
        if(!st.hasMoreTokens()) {
            st = new StringTokenizer(in.readLine());
        }
        return st.nextToken(delim);
    }
 
    String readLine() throws IOException {
        return in.readLine();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }

    long binpow(long a, long m) {
        if(m == 1)
            return a;
        long res = binpow(a, m / 2);
        if(m % 2 == 0)
            return (res * res) % mod;
        else
            return (((res * res) % mod) * a) % mod;
    }

    final long mod = 1_000_000_007;
    ArrayList<ArrayList<Integer>> g;
    ArrayList<ArrayList<Boolean>> ch;
    boolean[] used;
    long[][] dp;
    int[] x;
    public void solve() throws IOException {
        int n = nextInt();
        g = new ArrayList<ArrayList<Integer>>();
        ch = new ArrayList<ArrayList<Boolean>>();
        dp = new long[n][2];
        x = new int[n];
        used = new boolean[n];
        for(int i = 0; i < n; i++) {
            g.add(new ArrayList<Integer>());
            ch.add(new ArrayList<Boolean>());
        }
        for(int i = 0; i < n - 1; i++) {
            int x = nextInt();
            g.get(i + 1).add(x);
            ch.get(i + 1).add(false);
            g.get(x).add(i + 1);
            ch.get(x).add(false);
        }
        for(int i = 0; i < n; i++)
            x[i] = nextInt();
        dfs(0);
        out.println(dp[0][0]);
    }

    public void dfs(int v) {
        used[v] = true;
        boolean isLeaf = true;
        for(int i = 0; i < g.get(v).size(); i++) {
            if(!used[g.get(v).get(i)]) {
                isLeaf = false;
                ch.get(v).set(i, true);
                dfs(g.get(v).get(i));
            }
        }
        if(isLeaf) {
            if(x[v] == 0) {
                dp[v][0] = 0;
                dp[v][1] = 1;
            } else {
                dp[v][0] = 1;
                dp[v][1] = 0;
            }
        } else {
            if(x[v] == 1) {
                dp[v][0] = 1;
                for(int i =0 ; i < g.get(v).size(); i++) {
                    if(!ch.get(v).get(i)) continue;
                    int u = g.get(v).get(i);
                    if(x[u] == 1)
                        dp[v][0] = (dp[v][0] * dp[u][0]) % mod;
                    else
                        dp[v][0] = (dp[v][0] * (dp[u][0] + dp[u][1])) % mod;
                }
                dp[v][1] = 0;
            } else {
                dp[v][0] = 0;
                dp[v][1] = 1;
                for(int i = 0; i < g.get(v).size(); i++) {
                    if(!ch.get(v).get(i)) continue;
                    int u = g.get(v).get(i);
                    if(x[u] == 1)
                        dp[v][1] = (dp[v][1] * dp[u][0]) % mod;
                    else
                        dp[v][1] = (dp[v][1] * (dp[u][0] + dp[u][1])) % mod;
                }
                //one black adj
                long prod_black = 1;
                long prod_white = 1;
                for(int i = 0; i < g.get(v).size(); i++) {
                    int u = g.get(v).get(i);
                    if(!ch.get(v).get(i)) continue;
                    if(x[u] == 1) {
                        prod_black = (prod_black * dp[u][0]) % mod;
                    }
                    else {
                        prod_white = (prod_white * (dp[u][1] + dp[u][0])) % mod;
                    }
                }
                for(int i = 0; i < g.get(v).size(); i++) {
                    int u = g.get(v).get(i);
                    if(!ch.get(v).get(i)) continue;
                    if(x[u] == 1) {
                        //long temp = (prod_black * binpow(dp[u][0], mod - 2)) % mod;
                        dp[v][0] = (dp[v][0] + prod_black * prod_white) % mod;
                    }
                }
                for(int i = 0; i < g.get(v).size(); i++) {
                    int u = g.get(v).get(i);
                    if(!ch.get(v).get(i)) continue;
                    if(x[u] == 0) {
                        long temp = (prod_white * binpow(dp[u][0] + dp[u][1], mod - 2)) % mod;
                        dp[v][0] = (dp[v][0] + ((temp * dp[u][0]) % mod) * prod_black) % mod;
                    }
                }
            }
        }
    }
}