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;
using ii = pair<int, int>;
using ll = long long;
constexpr int MAXN = 5 + 200000;
constexpr int MOD = 7 + 1e9;
int c[MAXN], nodes, cnt[MAXN];
vector<int> g[MAXN], newt[MAXN];
int add(int a, int b) {
  int ans = a + b;
  if (ans >= MOD) ans -= MOD;
  return ans;
}
int mul(int a, int b) { return (int)((1LL * a * b) % MOD); }
void dfs(int u, int p) {
  if (p != -1) {
    g[u].erase(find(g[u].begin(), g[u].end(), p));
  }
  for (int v : g[u]) {
    dfs(v, u);
  }
}
int n;
int dfs2(int u) {
  cnt[u] = (u < n && c[u] == 1);
  for (int v : newt[u]) {
    cnt[u] += dfs2(v);
  }
  return cnt[u];
}
void mbin(int u, vector<int>::iterator s, vector<int>::iterator e) {
  int dist = distance(s, e);
  if (dist <= 2) {
    while (s != e) {
      newt[u].push_back(*s);
      mbin(*s, g[*s].begin(), g[*s].end());
      s++;
    }
  } else {
    newt[u].push_back(*s);
    mbin(*s, g[*s].begin(), g[*s].end());
    newt[u].push_back(nodes++);
    mbin(newt[u].back(), 1 + s, e);
  }
}
int memo[MAXN][2];
int dp(int u, int f) {
  int& ans = memo[u][f];
  if (ans != -1) return ans;
  int l = -1, r = -1;
  bool leaf = newt[u].empty();
  if (!leaf) l = newt[u][0], r = newt[u][1];
  assert(leaf || (int)newt[u].size() == 2);
  ans = 0;
  if (cnt[u] == 0 && f == 0) {
    return ans = 1;
  }
  if (u < n) {
    if (c[u] == 1) {
      if (f) {
        ans = dp(u, 0);
      } else {
        if (!leaf) {
          ans = mul(dp(l, cnt[l] >= 1), dp(r, cnt[r] >= 1));
        } else {
          ans = 1;
        }
      }
    } else {
      if (f) {
        assert(!leaf);
        ans = dp(u, 0);
        int m = 1;
        if (cnt[l] >= 1) m = mul(m, dp(l, 1));
        if (cnt[r] >= 1) m = mul(m, dp(r, 1));
        ans = add(ans, m);
      } else {
        if (!leaf) {
          if (cnt[l] >= 1 && cnt[r] >= 1) {
            ans = mul(dp(l, 0), dp(r, 1));
            ans = add(ans, mul(dp(l, 1), dp(r, 0)));
          } else if (cnt[l] >= 1) {
            ans = dp(l, 0);
          } else if (cnt[r] >= 1) {
            ans = dp(r, 0);
          } else {
            assert(false);
          }
        }
      }
    }
  } else {
    assert(!leaf);
    if (f) {
      if (cnt[l] >= 1 && cnt[r] >= 1) {
        ans = mul(dp(l, 1), dp(r, 1));
      } else if (cnt[l] >= 1) {
        ans = dp(l, 1);
      } else if (cnt[r] >= 1) {
        ans = dp(r, 1);
      } else
        assert(false);
    } else {
      if (cnt[l] >= 1 && cnt[r] >= 1) {
        ans = mul(dp(l, 0), dp(r, 1));
        ans = add(ans, mul(dp(l, 1), dp(r, 0)));
      } else if (cnt[l] >= 1) {
        ans = dp(l, 0);
      } else if (cnt[r] >= 1) {
        ans = dp(r, 0);
      }
    }
  }
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cin >> n;
  for (int i = 1; i < n; ++i) {
    int v;
    cin >> v;
    g[i].push_back(v);
    g[v].push_back(i);
  }
  for (int i = 0; i < n; ++i) {
    cin >> c[i];
  }
  dfs(0, -1);
  nodes = n;
  mbin(0, g[0].begin(), g[0].end());
  dfs2(0);
  for (int i = 0; i < nodes; ++i) {
    if (!newt[i].empty()) {
      while ((int)newt[i].size() < 2) {
        newt[i].push_back(MAXN - 1);
      }
    }
  }
  memset(memo, -1, sizeof memo);
  cout << dp(0, 0) << '\n';
  return 0;
}
