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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
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 {
    static final long MOD = (long) 1e9+7;
    public void solve(int testNumber, InputReader in, PrintWriter out) {
        int N = in.nextInt();
        Child[] childs = new Child[N];
        for (int i = 0; i < N-1; i++) {
            int p = in.nextInt();
            Child child = new Child(i+1);
            child.next = childs[p];
            childs[p] = child;
        }
        int[] color = new int[N];
        for (int i = 0; i < N; i++) {
            color[i] = in.nextInt();
        }
        long[][] dp = new long[N][2];
        for (int i = 0; i < N; i++) Arrays.fill(dp[i], -1);
        long ans = go(0, 0, childs, color, dp);
        out.println(ans);
    }

    private long go(int v, int b, Child[] childs, int[] color, long[][] dp) {
        if (dp[v][b] > -1) return dp[v][b];
        if (childs[v] == null) {
            if (b == 1 || color[v] == 1) return dp[v][b] = 1;
            else return dp[v][b] = 0;
        }
        long dpres = 0;
        if (b == 1 || color[v] == 1) {
            long res = 1;
            Child child = childs[v];
            while (child != null) {
                //long sum = go(child.v, 0, childs, color, dp) + go(child.v, 1, childs, color, dp);
                long sum = go(child.v, 1, childs, color, dp);
                res = (res*sum)%MOD;
                child = child.next;
            }
            dpres += res;
        }
        if (color[v] == 0) {
            ArrayList<Long> ltor = new ArrayList<>();
            ArrayList<Long> rtol = new ArrayList<>();
            Stack<Child> reverse = new Stack<>();
            Child child = childs[v];
            long times = 1;
            while (child != null) {
                reverse.add(child);
                times = (times * go(child.v, 1, childs, color, dp))%MOD;
                ltor.add(times);
                child = child.next;
            }
            int C = ltor.size();
            Child[] mychilds = new Child[C];
            int cp = C-1;
            times = 1;
            while (!reverse.isEmpty()) {
                child = reverse.pop();
                mychilds[cp--] = child;
                times = (times * go(child.v, 1, childs, color, dp))%MOD;
                rtol.add(times);
            }
            if (ltor.size() == 1) {
                //dpres = (dpres + ltor.get(0))%MOD;
                dpres = (dpres + go(mychilds[0].v, 0, childs, color, dp))%MOD;
            } else {
                dpres = (dpres + (go(mychilds[0].v, 0, childs, color, dp)*rtol.get(C-2))%MOD)%MOD;
                dpres = (dpres + (go(mychilds[C-1].v, 0, childs, color, dp)*ltor.get(C-2))%MOD)%MOD;
                for (int i = 1; i < C-1; i++) {
                    dpres = (dpres + (((go(mychilds[i].v, 0, childs, color, dp)*ltor.get(i-1))%MOD)*rtol.get(C-2-i))%MOD)%MOD;
                }
            }
        }
        return dp[v][b] = dpres;
    }

    static class Child {
        int v;
        Child next = null;

        Child(int v) {
            this.v = v;
        }
    }
}

class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream stream) {
        reader = new BufferedReader(new InputStreamReader(stream));
        tokenizer = null;
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

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

}

