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.InputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Rubanenko
 */
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 {

    final int MD = 1000_000_007;

    int[] a, next, last, color;
    long [] f, deg, f1;
    int k;
    boolean[] banned, used;

    void add(int x, int y) {
        k++;
        next[k] = last[x];
        last[x] = k;
        a[k] = y;
    }

    int[] d;

    long pow(long a, long b) {
        if (b == 0) return 1;
        if (b % 2 == 1) return pow(a, b - 1) * a % MD;
        a = a * a % MD;
        return pow(a, b / 2);
    }

    void dfs(int v, int p) {
        used[v] = true;
        int j = last[v];
        long prod = 1;
        while (j > 0) {
            if (a[j] == p) {
                j = next[j];
                continue;
            }
            dfs(a[j], v);
            prod = (prod * ((f[a[j]] + f1[a[j]]) % MD)) % MD;
            j = next[j];
        }
        f[v] = prod;
        if (color[v] == 1) {
            f1[v] = prod;
            f[v] = 0;
            return;
        }
        j = last[v];
        while (j > 0) {
            if (a[j] == p) {
                j = next[j];
                continue;
            }
            f1[v] = (f1[v] + ((f[v] * f1[a[j]]) % MD) * pow((f[a[j]] + f1[a[j]]) % MD, MD - 2)) % MD;
            j = next[j];
        }
    }

    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int n = in.nextInt();
        k = 0;
        a = new int[n * 2 + 1];
        next = new int[n * 2 + 1];
        last = new int[n + 1];
        f = new long[n + 1];
        deg = new long[n + 1];
        color = new int[n + 1];
        d = new int[n + 1];
        deg[0] = 1;
        banned = new boolean[n + 1];
        used = new boolean[n + 1];
        f1 = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            deg[i] = deg[i - 1] + deg[i - 1];
            if (deg[i] >= MD) deg[i] -= MD;
        }
        for (int i = 0;  i < n - 1; i++) {
            int p = in.nextInt();
            add(i + 1, p);
            add(p, i + 1);
            d[i + 1]++;
            d[p]++;
        }
        for (int i = 0; i < n; i++) {
            color[i] = in.nextInt();
        }
        dfs(0, -1);
        out.println(f1[0]);
    }
}

class InputReader {
    private BufferedReader reader;
    private StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        reader = new BufferedReader(new InputStreamReader(inputStream));
    }

    public String nextLine() {
        String line = null;
        try {
            line = reader.readLine();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return line;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens())
            tokenizer = new StringTokenizer(nextLine());
        return tokenizer.nextToken();
    }

    public int nextInt() {
        return Integer.parseInt(next());
    }
}

