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 sz = 2e5 + 5, mod = 1e9 + 7;
long long ans = 1;
int a[sz], csub[sz], fdp[sz], dp[sz];
vector<int> g[sz];
void go(int u, int p) {
  csub[u] = a[u];
  for (int v : g[u])
    if (v ^ p) go(v, u), csub[u] += csub[v];
}
int dfs(int u, int p, int d);
int fnc(int u, int p, int d) {
  int &w = fdp[u];
  if (w >= 0) return w;
  if (a[u]) {
    long long sum = 1;
    for (int v : g[u])
      if (v ^ p)
        if (csub[v]) sum = sum * dfs(v, u, 1) % mod;
    return w = sum;
  } else {
    int cnt = 0;
    for (int v : g[u])
      if (v ^ p) cnt += csub[v] > 0;
    if (cnt == 1)
      for (int v : g[u])
        if (v ^ p and csub[v]) return w = fnc(v, u, d + 1);
    vector<int> res, fuck;
    for (int v : g[u])
      if (v ^ p and csub[v]) {
        res.push_back(dfs(v, u, 1));
        fuck.push_back(fnc(v, u, 1));
      }
    long long sum = 0;
    vector<long long> suff(cnt), pref(cnt);
    pref[0] = res[0];
    for (int i = 1; i < cnt; i++) pref[i] = pref[i - 1] * res[i] % mod;
    suff.back() = res.back();
    for (int i = cnt - 2; i >= 0; i--) suff[i] = suff[i + 1] * res[i] % mod;
    for (int i = 0; i < cnt; i++) {
      long long now = fuck[i];
      if (i) now = now * pref[i - 1] % mod;
      if (i + 1 < cnt) now = now * suff[i + 1] % mod;
      sum += now;
    }
    return fdp[u] = sum % mod;
  }
}
int dfs(int u, int p, int d) {
  int &w = dp[u];
  if (w >= 0) return w;
  if (a[u]) {
    long long sum = d;
    for (int v : g[u])
      if (v ^ p)
        if (csub[v]) sum = sum * dfs(v, u, 1) % mod;
    return w = sum;
  } else {
    int cnt = 0;
    for (int v : g[u])
      if (v ^ p) cnt += csub[v] > 0;
    if (cnt == 1)
      for (int v : g[u])
        if (v ^ p and csub[v]) return w = dfs(v, u, d + 1);
    vector<int> res, fuck;
    for (int v : g[u])
      if (v ^ p and csub[v]) {
        res.push_back(dfs(v, u, 1));
        fuck.push_back(fnc(v, u, 1));
      }
    long long sum = 1;
    for (int v : res) sum = sum * v % mod;
    vector<long long> suff(cnt), pref(cnt);
    pref[0] = res[0];
    for (int i = 1; i < cnt; i++) pref[i] = pref[i - 1] * res[i] % mod;
    suff.back() = res.back();
    for (int i = cnt - 2; i >= 0; i--) suff[i] = suff[i + 1] * res[i] % mod;
    for (int i = 0; i < cnt; i++) {
      long long now = (long long)d * fuck[i] % mod;
      if (i) now = now * pref[i - 1] % mod;
      if (i + 1 < cnt) now = now * suff[i + 1] % mod;
      sum += now;
    }
    return w = sum % mod;
  }
}
int main() {
  int n;
  cin >> n;
  for (int i = 2; i <= n; i++) {
    int j;
    scanf("%d", &j);
    j++;
    g[j].push_back(i);
    g[i].push_back(j);
  }
  memset(dp, -1, sizeof(dp));
  memset(fdp, -1, sizeof(fdp));
  for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
  for (int i = 1; i <= n; i++)
    if (a[i]) {
      go(i, 0);
      cout << dfs(i, 0, 1);
      break;
    }
}
