#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;
int n, dp1[maxn], dp[maxn], c[maxn];
vector<int> v[maxn];
void enter() {
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int x;
    cin >> x;
    v[x].push_back(i + 1);
    v[i + 1].push_back(x);
  }
  for (int i = 0; i < n; ++i) cin >> c[i];
}
int P(int a, int b) {
  if (b == 0) return 1;
  long long r = P(a, b >> 1);
  if (b & 1) return 1ll * r * r % mod * (long long)a % mod;
  return 1ll * r * r % mod;
}
void DFS(int u, int par) {
  if (v[u].size() == 1 && u != 0) {
    dp[u] = c[u];
    dp1[u] = c[u] ^ 1;
    return;
  }
  int r = 1;
  for (int c : v[u]) {
    if (c == par) continue;
    DFS(c, u);
    r = 1ll * r * (dp[c] + dp1[c]) % mod;
  }
  dp[u] = dp1[u] = 0;
  int d = 0;
  for (int c : v[u]) {
    if (c == par) continue;
    int k = dp[c] + dp1[c];
    d = (d + (long long)r * P(k, mod - 2) % mod * dp[c] % mod) % mod;
  }
  if (c[u])
    dp1[u] = 0, dp[u] = r;
  else
    dp1[u] = r, dp[u] = d;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  enter();
  DFS(0, -1);
  cout << dp[0];
  return 0;
}
