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.util.ArrayList;
import java.util.List;
import java.util.Scanner;
/*
10
0 0 1 2 0 5 1 2 3
1 0 0 1 0 0 1 1 0 1


使得每一个连通块内只有一个白色结点

输出样例2：
f[u]表示u子树有一个白点的方案数
g[u]表示u子树没有白点的方案数
f[u]=f[u]*g[son]+f[u]*f[son]+g[u]*f[son]
g[u]=g[u]*g[son]+g[u]*f[son]
递归终止  如果当前节点是 白色
 */
public class Main {
    static long[] f;
    static long[] g;
    final static long mod = 1000000007;
    public static void dfs(List[] tree,int[]color,int idx,int fd){
        if(color[idx] == 1)f[idx] = 1;
        else g[idx] = 1;
        List<Integer> nexts = tree[idx];
        for(Integer next : nexts){
            if(next == fd)continue;
            dfs(tree,color,next,idx);
            f[idx] =(f[idx]*g[next]%mod + f[next]*f[idx]%mod + g[idx] *f[next]%mod)%mod;
            g[idx] =(g[idx]*g[next]%mod + g[idx] * f[next]%mod)%mod;
        }
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer>[] tree = new ArrayList[n];
        for (int i = 0; i <n ; i++) {
            tree[i] = new ArrayList<>();
        }
        // 连接 当前节点 i+1和读入的father
        for (int i = 0; i <n-1 ; i++) {
            int fd = sc.nextInt();
            tree[fd].add(i+1);
            tree[i+1].add(fd);
        }
        int[] color = new int[n];
        f = new long[n];
        g = new long[n];
        // 每个节点的颜色 0 白色 1 黑色
        for (int i = 0; i <n ; i++) {
            color[i] = sc.nextInt();
        }
        dfs(tree,color,0,-1);
        System.out.println(f[0]);
    }
}
