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
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 5, MOD = 1e9 + 7;
int n, c[MAX], f[MAX], g[MAX], pref[MAX], suff[MAX];
vector<int> tmp, gt[MAX];
void dfs(int x, int p) {
  if (x > 0 && gt[x].size() == 1) {
    f[x] = !c[x];
    g[x] = c[x];
    return;
  }
  if (c[x] == 0) {
    f[x] = 1;
    g[x] = 0;
    for (int i = 0; i < gt[x].size(); i++) {
      int y = gt[x][i];
      if (y == p) continue;
      dfs(y, x);
      f[x] = (f[x] * 1LL * (f[y] + g[y])) % MOD;
    }
  } else {
    f[x] = 0;
    g[x] = 1;
    for (int i = 0; i < gt[x].size(); i++) {
      int y = gt[x][i];
      if (y == p) continue;
      dfs(y, x);
      g[x] = (g[x] * 1LL * (f[y] + g[y])) % MOD;
    }
    for (int i = 0; i < gt[x].size(); i++) {
      int y = gt[x][i];
      if (y == p) continue;
      tmp.push_back(y);
    }
    for (int i = 0; i < tmp.size(); i++) {
      int y = tmp[i];
      pref[i] = (f[y] + g[y]) % MOD;
      if (i > 0) pref[i] = (pref[i] * 1LL * pref[i - 1]) % MOD;
    }
    for (int i = tmp.size() - 1; i >= 0; i--) {
      int y = tmp[i];
      suff[i] = (f[y] + g[y]) % MOD;
      if (i < tmp.size() - 1) suff[i] = (suff[i] * 1LL * suff[i + 1]) % MOD;
      int ans = f[y];
      if (i > 0) ans = (ans * 1LL * pref[i - 1]) % MOD;
      if (i < tmp.size() - 1) ans = (ans * 1LL * suff[i + 1]) % MOD;
      f[x] = (f[x] + ans) % MOD;
    }
    for (int i = 0; i < tmp.size(); i++) {
      int y = tmp[i];
      pref[y] = suff[y] = 0;
    }
    tmp.clear();
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x;
    scanf("%d", &x);
    gt[x].push_back(i);
    gt[i].push_back(x);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &c[i]);
    c[i] = !c[i];
  }
  dfs(0, -1);
  printf("%d\n", f[0]);
  return 0;
}
