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 com.company;

import java.io.*;
import java.util.*;

public class Main {
    static long TIME_START, TIME_END;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(System.out);
//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.in"));
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
//        pw.println("Time used: " + (TIME_END - TIME_START) + ".");
        pw.close();
    }


    public static class Task {

        int MOD = 1000000007;
        List<Integer>[] child;
        int[] color;
        long[][] dp;
        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            color = new int[n];
            child = new List[n];
            for (int i = 0; i < n; i++) {
                child[i] = new ArrayList<>();
            }
            dp = new long[n][2];
            for (int i = 0; i < n - 1; i++) {
                int p = sc.nextInt();
                child[p].add(i + 1);
            }
            for (int i = 0; i < n; i++) {
                color[i] = sc.nextInt();
            }
            dfs(0);
            pw.println(dp[0][1]);
        }

        public void dfs(int u) {
            if (child[u].size() == 0) {
                dp[u][color[u]] = 1;
                dp[u][0] = 1;
                return;
            }
            if (color[u] == 1) {
                long t = 1;
                for (int v : child[u]) {
                    dfs(v);
                    t *= dp[v][0];
                    t %= MOD;
                }
                dp[u][0] = t;
                dp[u][1] = t;
            } else {
                long t = 1;
                for (int v : child[u]) {
                    dfs(v);
                    t *= dp[v][0];
                    t %= MOD;
                }
                for (int v : child[u]) {
                    dp[u][1] += dp[v][1] * t % MOD * powmod(dp[v][0], MOD - 2) % MOD;
                    if (dp[u][1] >= MOD) {
                        dp[u][1] -= MOD;
                    }
                }
                dp[u][0] = t + dp[u][1];
            }
        }
        public int powmod(long a, int b) {
            if (b == 0) return 1;
            if (b % 2 == 0) return powmod(a * a % MOD, b >> 1);
            return (int) (a * powmod(a * a % MOD, b >> 1) % MOD);
        }
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

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

        public Scanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

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

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

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

        public String nextLine() throws IOException {return br.readLine();}

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

        public boolean ready() throws IOException {return br.ready();}
    }
}
