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
/**
 * author: derrick20
 * created: 9/23/20 2:21 PM
 */
import java.io.*;
import java.util.*;

public class ApplemanAndTree implements Runnable {
    public static void main(String[] args) throws Exception {
        new Thread(null, new ApplemanAndTree(), ": )", 1 << 28).start();
    }

    public void run() {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        int N = sc.nextInt();
        int[] par = new int[N];
        for (int i = 1; i < N; i++) {
            par[i] = sc.nextInt();
        }
        adjList = new ArrayList[N];
        Arrays.setAll(adjList, i -> new ArrayList<>());
        for (int i = 1; i < N; i++) {
            int u = par[i];
            adjList[u].add(i);
        }
        color = sc.nextInts(N);
        dp = new long[2][N];
        solve(0);
        out.println(dp[1][0]);
        out.close();
    }
    static ArrayList<Integer>[] adjList;
    static long[][] dp;
    static int[] color;
    static long mod = (long) 1e9 + 7;

    /*
    dp[color][node] = number of ways to divide our subtree so that all components
    all have 1 black node, and so that the component that node is a part of is the
    color specified.
     */
    static void solve(int node) {
        for (int adj : adjList[node]) {
            solve(adj);
        }
        /*
        More intuitive method:
        No base cases needed!
        Imagine moving through children and building the ways for our component to work:
        Start off with our single node as the component. (1, 0) or (0, 1) is our solution
        counts currently.
         */
        long[] curr = new long[2];
        curr[color[node]] = 1;
        for (int adj : adjList[node]) {
            /*
            Then, as we consider incorporating each additional child, we can multiply the ways
            to build our already formed component and the ways to build the new component to be
            merged.
             */
            long[] next = new long[2];
            /*
            We can expand our current white component in exactly 1 way if we add the child's
            white or black component. For the white component, just merge it. For the black component
            we must cut the edge. Note, that these are the ONLY ways to combine it, which is why
            the scale factor is just 1.
            Also, note that next[0] will always be 0 if our initial component (color[node]) was black.
             */
            next[0] = (curr[0] * (dp[0][adj] + dp[1][adj])) % mod;
            /*
            We can create a new black component by mixing a previously white component
            with the black child (just connect them, only 1 valid way). We can also
            expand our old black component by connecting with a white child,
            or cutting the edge to the black child.

            The transitions look somewhat similar between these two lines, but are actually different
            The transition in the previous case was: [white + white, white | black]
            Here, it's [white + black, black + white, black | black]
            (+ means joining, | means separating)
            But each of these occur in 1 way, so they add up similarly.
             */
            next[1] = (curr[0] * dp[1][adj] + curr[1] * (dp[0][adj] + dp[1][adj])) % mod;
            curr = next;
        }
        dp[0][node] = curr[0];
        dp[1][node] = curr[1];
    }

    static class FastScanner {
        private int BS = 1 << 16;
        private char NC = (char) 0;
        private byte[] buf = new byte[BS];
        private int bId = 0, size = 0;
        private char c = NC;
        private double cnt = 1;
        private BufferedInputStream in;

        public FastScanner() {
            in = new BufferedInputStream(System.in, BS);
        }

        public FastScanner(String s) {
            try {
                in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
            } catch (Exception e) {
                in = new BufferedInputStream(System.in, BS);
            }
        }

        private char getChar() {
            while (bId == size) {
                try {
                    size = in.read(buf);
                } catch (Exception e) {
                    return NC;
                }
                if (size == -1) return NC;
                bId = 0;
            }
            return (char) buf[bId++];
        }

        public int nextInt() {
            return (int) nextLong();
        }

        public int[] nextInts(int N) {
            int[] res = new int[N];
            for (int i = 0; i < N; i++) {
                res[i] = (int) nextLong();
            }
            return res;
        }

        public long[] nextLongs(int N) {
            long[] res = new long[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextLong();
            }
            return res;
        }

        public long nextLong() {
            cnt = 1;
            boolean neg = false;
            if (c == NC) c = getChar();
            for (; (c < '0' || c > '9'); c = getChar()) {
                if (c == '-') neg = true;
            }
            long res = 0;
            for (; c >= '0' && c <= '9'; c = getChar()) {
                res = (res << 3) + (res << 1) + c - '0';
                cnt *= 10;
            }
            return neg ? -res : res;
        }

        public double nextDouble() {
            double cur = nextLong();
            return c != '.' ? cur : cur + nextLong() / cnt;
        }

        public double[] nextDoubles(int N) {
            double[] res = new double[N];
            for (int i = 0; i < N; i++) {
                res[i] = nextDouble();
            }
            return res;
        }

        public String next() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c > 32) {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public String nextLine() {
            StringBuilder res = new StringBuilder();
            while (c <= 32) c = getChar();
            while (c != '\n') {
                res.append(c);
                c = getChar();
            }
            return res.toString();
        }

        public boolean hasNext() {
            if (c > 32) return true;
            while (true) {
                c = getChar();
                if (c == NC) return false;
                else if (c > 32) return true;
            }
        }
    }
    static void ASSERT(boolean assertion, String message) {
        if (!assertion) throw new AssertionError(message);
    }
    static void ASSERT(boolean assertion) {
        if (!assertion) throw new AssertionError();
    }
}