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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.math.BigInteger;
import java.util.StringTokenizer;

/**
 * @author Pavel Mavrin
 */
public class B {

    private static final long MOD = 1000000007;
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st;
    PrintStream out = System.out;

    String next() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }

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

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

    private void solve() throws IOException {
        int n = nextInt();
        IntList[] c = new IntList[n];
        for (int i = 0; i < n; i++) c[i] = new IntList();
        for (int i = 1; i < n; i++) {
            c[nextInt()].add(i);
        }
        boolean[] b = new boolean[n];
        for (int i = 0; i < n; i++) b[i] = nextInt() == 1;
        long[] d1 = new long[n];
        long[] d2 = new long[n];
        for (int i = n - 1; i >= 0; i--) {
            if (b[i]) {
                d2[i] = 0;
                d1[i] = 1;
                for (int j = 0; j < c[i].size; j++) {
                    int x = c[i].get(j);
                    d1[i] *= (d1[x] + d2[x]);
                    d1[i] %= MOD;
                }
            } else {
                d2[i] = 1;
                for (int j = 0; j < c[i].size; j++) {
                    int x = c[i].get(j);
                    d2[i] *= (d1[x] + d2[x]);
                    d2[i] %= MOD;
                }
                d1[i] = 0;
                for (int j = 0; j < c[i].size; j++) {
                    int x = c[i].get(j);
                    long z = d2[i] * d1[x];
                    z %= MOD;
                    z *= inv(d1[x] + d2[x]);
                    z %= MOD;
                    d1[i] += z;
                    d1[i] %= MOD;
                }
            }
        }
        out.println(d1[0]);
    }

    private long inv(long l) {
        return BigInteger.valueOf(l).modInverse(BigInteger.valueOf(MOD)).longValue();
    }

    class IntList {
        int[] ints = new int[1];
        int size;
        void add(int v) {
            if (size == ints.length) {
                int[] newInts = new int[ints.length * 2];
                System.arraycopy(ints, 0, newInts, 0, ints.length);
                ints = newInts;
            }
            ints[size++] = v;
        }
        int get(int i) {
            return ints[i];
        }
    }
}
