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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BApplemanAndTree solver = new BApplemanAndTree();
        solver.solve(1, in, out);
        out.close();
    }

    static class BApplemanAndTree {
        int n;
        ArrayList<Integer>[] adjL;
        int[] color;
        long[][] dp;
        int mod = (int) 1e9 + 7;

        long modPow(long a, long e, int mod) {
            a %= mod;
            long res = 1;
            while (e > 0) {
                if ((e & 1) == 1)
                    res = (res * a) % mod;
                a = (a * a) % mod;
                e >>= 1;
            }
            return res;
        }

        public void solve(int testNumber, Scanner sc, PrintWriter pw) {
            n = sc.nextInt();
            adjL = new ArrayList[n];
            for (int i = 0; i < n; i++)
                adjL[i] = new ArrayList<>();
            for (int i = 0; i < n - 1; i++) {
                int u = sc.nextInt();
                adjL[u].add(i + 1);
            }
            color = new int[n];
            for (int i = 0; i < n; i++)
                color[i] = sc.nextInt();
            dp = new long[n][2];
            dfs(0);
            pw.println(dp[0][1]);
        }

        private void dfs(int u) {
            if (color[u] == 1) {
                if (adjL[u].size() == 0) {
                    dp[u][1] = 1;
                    dp[u][0] = 0;
                    return;
                }
                for (int v : adjL[u])
                    dfs(v);
                long mul = 1;
                for (int v : adjL[u]) {
                    mul *= (dp[v][0] + dp[v][1]) % mod;
                    mul %= mod;
                }
                dp[u][1] += mul;
                dp[u][1] %= mod;
            } else {
                if (adjL[u].size() == 0) {
                    dp[u][1] = 0;
                    dp[u][0] = 1;
                    return;
                }
                for (int v : adjL[u])
                    dfs(v);
                long mul = 1;
                for (int v : adjL[u]) {
                    mul *= (dp[v][0] + dp[v][1]) % mod;
                    mul %= mod;
                }
                dp[u][0] += mul;
                for (int v : adjL[u]) {
                    long temp = mul * modPow(dp[v][1] + dp[v][0], mod - 2, mod);
                    temp %= mod;
                    dp[u][1] += dp[v][1] * temp % mod;
                    dp[u][1] %= mod;
                }
            }
        }

    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() {
            try {
                while (st == null || !st.hasMoreTokens())
                    st = new StringTokenizer(br.readLine());
                return st.nextToken();
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }

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

    }
}

