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
//package codeforces;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;

public class B {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    PrintWriter writer = new PrintWriter(System.out);
    StringTokenizer stringTokenizer;

    String next() throws IOException {
        while (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
            stringTokenizer = new StringTokenizer(reader.readLine());
        }
        return stringTokenizer.nextToken();
    }

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

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

    @SuppressWarnings("unchecked")
    void solve() throws IOException {
        final int n = nextInt();
        final List<List<Integer>> g = new ArrayList<>();
        for(int i = 0; i < n; i++) {
            g.add(new ArrayList<Integer>());
        }
        for(int u = 1; u < n; u++) {
            int v = nextInt();
            g.get(u).add(v);
            g.get(v).add(u);
        }
        final int[] color = new int[n];
        for(int i = 0; i < n; i++) {
            color[i] = nextInt();
        }
        class Utils {
            int root;
            int[] parent = new int[n];
            int[] blackCounts = new int[n];
            {
                while(color[root] == 0) {
                    root++;
                }
                Arrays.fill(parent, -1);
                parent[root] = root;
                countBlacks(root);
            }

            void countBlacks(int u) {
                blackCounts[u] = color[u];
                for (int v : g.get(u)) {
                    if(parent[v] == -1) {
                        parent[v] = u;
                        countBlacks(v);
                        blackCounts[u] += blackCounts[v];
                    }
                }
            }

            final int MOD = 1000 * 1000 * 1000 + 7;

            int blackPartitions(int u, int canJoinParent) {
                if(blackCounts[u] == 0) {
                    return canJoinParent;
                }
                if(color[u] == 1) {
                    int result = 1;
                    for (Integer v : g.get(u)) {
                        if(v != parent[u]) {
                            result = product(result, blackPartitions(v, 1));
                        }
                    }
                    return result;
                } else {
                    int[] childrenBlackPartitions = new int[g.get(u).size()];
                    Integer[] children = g.get(u).toArray(new Integer[g.get(u).size()]);
                    for(int i = 0; i < children.length; i++) {
                        int v = children[i];
                        childrenBlackPartitions[i] = v == parent[u] ? 1 : blackPartitions(v, 1);
                    }
                    int childrenProduct = 1;
                    for (int childrenBlackPartition : childrenBlackPartitions) {
                        childrenProduct = product(childrenProduct, childrenBlackPartition);
                    }
                    int result = 0;
                    for(int i = 0; i < children.length; i++) {
                        int v = children[i];
                        result = sum(result, v == parent[u] ? (canJoinParent == 1 ? childrenProduct : 0) : product(childrenProduct,
                                product(inv(childrenBlackPartitions[i]), blackPartitions(v, 0))));
                    }
                    return result;
                }
            }

            int blackPartitions() {
                return blackPartitions(root, 0);
            }

            int sum(int a, int b) {
                a += b;
                return a >= MOD ? a - MOD : a;
            }
            int product(int a, int b) {
                return (int)(1L * a * b % MOD);
            }
            int power(int x, int k) {
                int result = 1;
                while(k > 0) {
                    if(k % 2 == 1) {
                        result = product(result, x);
                    }
                    x = product(x, x);
                    k /= 2;
                }
                return result;
            }
            int inv(int x) {
                return power(x, MOD - 2);
            }
        }
        
        class CachingUtils extends Utils {
            int[][] cache = new int[n][2];
            boolean[][] visited = new boolean[n][2];
            @Override
            int blackPartitions(int u, int canJoinParent) {
                if(visited[u][canJoinParent]) {
                    return cache[u][canJoinParent];
                }
                visited[u][canJoinParent] = true;
                return cache[u][canJoinParent] = super.blackPartitions(u, canJoinParent);
            }
        }
        writer.println(new CachingUtils().blackPartitions());
        writer.close();
    }



    public static void main(String[] args) throws IOException {
        new B().solve();
    }
}
