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.*;
import java.util.*;

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

    void solve() throws IOException {
        FastScanner sc = new FastScanner(System.in);

        int n = sc.nextInt();
        int[] bw = new int[n];
        int[] par = new int[n];
        LinkedList<Integer>[] ch = new LinkedList[n];
        {
            for (int i = 0; i < ch.length; i++) {
                ch[i] = new LinkedList<Integer>();
            }

            for (int i = 1; i < n; i++) {
                par[i] = sc.nextInt();
                ch[par[i]].add(i);
            }
            for (int i = 0; i < n; i++) {
                bw[i] = sc.nextInt();
            }
        }

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

        for (int i = n - 1; i >= 0; i--) {
            if (ch[i].size() == 0) {
                dp[i][0] = bw[i];
                dp[i][1] = 1;
            } else {
                if (bw[i] == 0) {

                    // 0
                    for (int t : ch[i]) {
                        dp[i][0] += mul[i][1] * inv(dp[t][1]) % mod * dp[t][0];
                        dp[i][0] %= mod;
                    }


                    // 1
                    dp[i][1] = dp[i][0] + mul[i][1];
                    dp[i][1] %= mod;

                } else {// bw[i] == 1
                    dp[i][0] = dp[i][1] = mul[i][1];
                }
            }

            mul[par[i]][0] *= dp[i][0];
            mul[par[i]][0] %= mod;
            mul[par[i]][1] *= dp[i][1];
            mul[par[i]][1] %= mod;
        }

        System.out.println(dp[0][0]);
    }


    long mod = 1000000007;

    // a^-1 = a^(p-2)
    long inv(long a) {
        return powlong(a, mod - 2, mod);
    }

    long powlong(long a, long b, long mod) {
        long ret = 1;
        while (b != 0) {
            if ((b & 1) == 1) {
                ret *= a;
                ret %= mod;
            }
            b >>= 1;
            a = a * a % mod;
        }
        return ret;
    }














    class FastScanner {

        private InputStream _stream;
        private byte[] _buf = new byte[1024];
        private int _curChar;
        private int _numChars;
        private StringBuilder _sb = new StringBuilder();

        FastScanner(InputStream stream) {
            this._stream = stream;
        }

        public int read() {
            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 String next() {
            int c = read();
            while (isWhitespace(c)) {
                c = read();
            }
            _sb.setLength(0);
            do {
                _sb.appendCodePoint(c);
                c = read();
            } while (!isWhitespace(c));
            return _sb.toString();
        }

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

        public boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
//
