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.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;

/**
 * Created by hama_du on 2014/08/09.
 */
public class ProblemB {
    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = in.nextInt();
        graph = new List[n];
        for (int i = 0 ; i < n ; i++) {
            graph[i] = new ArrayList<Integer>();
        }
        for (int i = 0 ; i < n-1 ; i++) {
            int a = in.nextInt();
            int b = i+1;
            graph[a].add(b);
            graph[b].add(a);
        }
        isBlack = new boolean[n];
        blackCount = new int[n];
        for (int i = 0 ; i < n ; i++) {
            isBlack[i] = in.nextInt() == 1;
        }
        dfs(0, -1);

        memo = new long[n][2];
        for (int i = 0 ; i < n ; i++) {
            memo[i][0] = memo[i][1] = -1;
        }


        p2 = new long[1000000];
        p2[0] = 1;
        for (int i = 1 ; i < n ; i++) {
            p2[i] = p2[i-1] * 2;
            p2[i] %= MOD;
        }

        out.println(dfs2(0, 1, -1));
        out.flush();
    }

    static List<Integer>[] graph;
    static boolean[] isBlack;
    static int[] blackCount;

    static long[] p2;

    static long[][] memo;

    static int dfs(int now, int parent) {
        int cnt = 0;
        if (isBlack[now]) {
            cnt++;
        }
        for (int to : graph[now]) {
            if (to != parent) {
                cnt += dfs(to, now);
            }
        }
        blackCount[now] = cnt;
        return cnt;
    }

    static long dfs2(int now, int want, int parent) {
        if (memo[now][want] != -1) {
            return memo[now][want];
        }

        List<Long> yesWant = new ArrayList<Long>();
        List<Long> noWant = new ArrayList<Long>();
        List<Boolean> black = new ArrayList<>();
        for (int to : graph[now]) {
            if (to != parent && blackCount[to] >= 1) {
                yesWant.add(dfs2(to, 1, now));
                noWant.add(dfs2(to, 0, now));
                black.add(isBlack[to]);
            }
        }

        int len = yesWant.size();
        long[][] dp = new long[len+1][2];
        if (isBlack[now]) {
            dp[0][1] = 1;
        } else {
            dp[0][0] = 1;
        }
        for (int i = 0 ; i < len ; i++) {
            for (int j = 0 ; j <= 1 ; j++) {
                long base = dp[i][j];
                if (black.get(i)) {
                    if (j == 0) {
                        dp[i+1][1] += (base * noWant.get(i)) % MOD;
                        dp[i+1][1] %= MOD;
                    }

                    dp[i+1][j] += (base * yesWant.get(i)) % MOD;
                    dp[i+1][j] %= MOD;
                } else {
                    if (j == 0) {
                        dp[i+1][1] += (base * yesWant.get(i)) % MOD;
                        dp[i+1][j] %= MOD;
                    }

                    dp[i+1][j] += (base * ((noWant.get(i) + yesWant.get(i)) % MOD) % MOD);
                    dp[i+1][j] %= MOD;
                }
            }
        }

        memo[now][want] = dp[len][want];
        if (isBlack[now]) {
            if (want == 0) {
                memo[now][want] = dp[len][1];
            }
        }

        return memo[now][want];
    }

    static final long MOD = 1000000007;

    static void debug(Object... obj) {
        System.err.println(Arrays.deepToString(obj));
    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int next() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = next();
            while (isSpaceChar(c))
                c = next();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = next();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = next();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }

}
