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

public class Main {
    final static int MOD = (int)1e9 + 7;

    long add(long x, long a) {
        x += a;
        if (x >= MOD) {
            x -= MOD;
        }
        return x;
    }

    long[] solve(List <List <Integer>> edges, int[] color, int p, int u) {
        long[] subtrees = new long[]{1, 0};
        for (int v : edges.get(u)) {
            if (v != p) {
                long[] subtree = solve(edges, color, u, v);
                long[] newSubtrees = new long[2];
                for (int i = 0; i < 2; ++ i) {
                    for (int j = 0; j < 2; ++ j) {
                        if (i + j < 2) {
                            newSubtrees[i + j] = add(newSubtrees[i + j], subtrees[i] * subtree[j] % MOD);
                        }
                        if (j == 1) {
                            newSubtrees[i] = add(newSubtrees[i], subtrees[i] * subtree[j] % MOD);
                        }
                    }
                }
                subtrees = newSubtrees;
            }
        }
        if (color[u] == 1) {
            return new long[]{0, subtrees[0]};
        } else {
            return subtrees;
        }
    }

    public void run() {
        int n = reader.nextInt();
        List <List <Integer>> edges = new ArrayList <List <Integer>>();
        for (int i = 0; i < n; ++ i) {
            edges.add(new ArrayList <Integer>());
        }
        for (int i = 1; i < n; ++ i) {
            int p = reader.nextInt();
            edges.get(i).add(p);
            edges.get(p).add(i);
        }
        int[] color = new int[n];
        for (int i = 0; i < n; ++ i) {
            color[i] = reader.nextInt();
        }
        long[] result = solve(edges, color, -1, 0);
        writer.println(result[1]);
        writer.close();
    }

    Main() {
        reader = new InputReader(System.in);
        writer = new PrintWriter(System.out);
    }

    public static void main(String[] args) {
        new Main().run();
    }

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

    private InputReader reader;
    private PrintWriter writer;
}

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

    public int nextChar() {
        if (charCount == -1)
            throw new InputMismatchException();
        if (head >= charCount) {
            head = 0;
            try {
                charCount = stream.read(buffer);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (charCount <= 0)
                return -1;
        }
        return buffer[head ++];
    }

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

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

    private InputStream stream;
    private int head, charCount;
    private byte[] buffer = new byte[1024];
}
