#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int n;
int c[100005];
long long dp[100005][2];
vector<int> g[100005];
long long modpow(long long a, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans = (ans * a) % mod;
    a = (a * a) % mod;
    n >>= 1;
  }
  return ans;
}
long long inv(long long a) { return modpow(a, mod - 2); }
void dfs(int u) {
  if (dp[u][1] || dp[u][0]) return;
  if (c[u] == 1) {
    dp[u][0] = 0;
    dp[u][1] = 1;
    for (int i = 0; i < (int)g[u].size(); i++) {
      int v = g[u][i];
      dfs(v);
      dp[u][1] = (dp[u][1] * ((dp[v][0] + dp[v][1]) % mod)) % mod;
    }
    return;
  }
  dp[u][0] = 1;
  for (int i = 0; i < (int)g[u].size(); i++) {
    int v = g[u][i];
    dfs(v);
    dp[u][0] = (dp[u][0] * ((dp[v][0] + dp[v][1]) % mod)) % mod;
  }
  long long full = 1;
  for (int i = 0; i < (int)g[u].size(); i++) {
    int v = g[u][i];
    full = (full * ((dp[v][0] + dp[v][1]) % mod)) % mod;
  }
  for (int i = 0; i < (int)g[u].size(); i++) {
    int v = g[u][i];
    dp[u][1] = (dp[u][1] + full * inv((dp[v][0] + dp[v][1]) % mod) % mod *
                               dp[v][1] % mod) %
               mod;
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int p;
    scanf("%d", &p);
    g[p].push_back(i);
  }
  for (int i = 0; i < n; i++) scanf("%d", &c[i]);
  dfs(0);
  printf("%I64d\n", dp[0][1]);
  return 0;
}
