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;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  std::cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  std::cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
template <typename T, typename U>
static inline void amin(T& x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
static inline void amax(T& x, U y) {
  if (x < y) x = y;
}
long long max(long long a, long long b) { return (a > b) ? a : b; }
long long min(long long a, long long b) { return (a < b) ? a : b; }
const long long N = 1e5 + 10;
vector<long long> adj[N];
long long inv[N];
long long mark[N];
void modularInverse(long long n, long long prime) {
  inv[0] = inv[1] = 1;
  for (long long i = 2; i <= n; i++)
    inv[i] = inv[prime % i] * (prime - prime / i) % prime;
}
long long power(long long x, unsigned long long y, unsigned long long m) {
  if (y == 0) return 1;
  long long p = power(x, y / 2, m) % m;
  p = (p * p) % m;
  return (y % 2 == 0) ? p : (x * p) % m;
}
long long dp[N][2];
void dfs(long long v, long long p) {
  for (auto i : adj[v]) {
    if (i == p) continue;
    dfs(i, v);
  }
  if (mark[v]) {
    dp[v][0] = 0;
    dp[v][1] = 1;
    for (auto i : adj[v]) {
      if (i == p) continue;
      dp[v][1] *= (dp[i][0] + dp[i][1]);
      dp[v][1] %= 1000000007;
    }
  } else {
    dp[v][0] = 1;
    for (auto i : adj[v]) {
      if (i == p) continue;
      dp[v][0] *= (dp[i][0] + dp[i][1]);
      dp[v][0] %= 1000000007;
    }
    for (auto i : adj[v]) {
      if (i == p) continue;
      dp[v][1] += (((dp[v][0] *
                     power(dp[i][0] + dp[i][1], 1000000007 - 2, 1000000007)) %
                    1000000007) *
                   dp[i][1]) %
                  1000000007;
      dp[v][1] %= 1000000007;
    }
  }
}
long long solve() {
  long long n;
  cin >> n;
  for (long long i = 2; i <= n; i++) {
    long long x;
    cin >> x;
    x++;
    adj[x].push_back(i);
    adj[i].push_back(x);
  }
  for (long long i = 1; i <= n; i++) {
    long long x;
    cin >> x;
    mark[i] = x;
  }
  dfs(1, 0);
  cout << dp[1][1];
  return 0;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  modularInverse(N - 1, 1000000007);
  while (t--) {
    solve();
  }
  return 0;
}
