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

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

class TaskB {
    private static final long MOD = 1000000007;
    ArrayList<Integer>[] G;
    int[] X;
    int[][] mem;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int N = in.nextInt();
        G = new ArrayList[N];
        for (int i = 0; i < N; i++) {
            G[i] = new ArrayList<Integer>();
        }
        for (int i = 1; i <= N - 1; i++) {
            int p = in.nextInt();
            G[p].add(i);
        }

        X = new int[N];
        for (int i = 0; i < N; i++) {
            X[i] = in.nextInt();
        }

        mem = new int[N][2];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 2; j++) {
                mem[i][j] = -1;
            }
        }
        int ans = go(0, 0);

        out.println(ans);
    }

    private int go(int node, int t) {
        if (X[node] == 1) {
            if (t == 1) {
                return 0;
            }
            t = 1;
        }
        if (mem[node][t] > -1) {
            return mem[node][t];
        }

        int K = G[node].size();
        int ret = 0;

        if (K == 0) {
            if (t == 1) {
                ret = 1;
            }
        }
        else {
            long[] A = new long[K];
            for (int i = 0; i < K; i++) {
                if (i > 0) {
                    A[i] = A[i - 1];
                }
                else {
                    A[i] = 1;
                }
                int p = G[node].get(i);
                int crt = go(p, 0);
                crt += go(p, 1);
                A[i] = A[i] * crt % MOD;
            }

            if (t == 1) {
                ret = (int) A[K - 1];
            } else {
                long[] B = new long[K];
                for (int i = K - 1; i >= 0; i--) {
                    if (i < K - 1) {
                        B[i] = B[i + 1];
                    }
                    else {
                        B[i] = 1;
                    }
                    int p = G[node].get(i);
                    int crt = go(p, 0);
                    crt += go(p, 1);
                    B[i] = B[i] * crt % MOD;
                }

                for (int i = 0; i < G[node].size(); i++) {
                    int p = G[node].get(i);
                    long crt = go(p, 0);
                    if (i > 0) {
                        crt = crt * A[i - 1] % MOD;
                    }
                    if (i + 1 < K) {
                        crt = crt * B[i + 1] % MOD;
                    }
                    ret += crt;
                    if (ret >= MOD) {
                        ret -= MOD;
                    }
                }
            }
        }

        mem[node][t] = ret;
        return ret;
    }
}

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

    public InputReader(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 int nextInt() {
        return Integer.parseInt(nextString());
    }

    public String nextString() {
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuffer res = new StringBuffer();
        do {
            res.appendCodePoint(c);
            c = read();
        } while (!isSpaceChar(c));

        return res.toString();
    }

    private boolean isSpaceChar(int c) {
        return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
    }

}

