#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long pwr(long long a, long long b, long long mod) {
  if (b == 0) return 1;
  long long temp = pwr(a, b / 2, mod);
  temp = (temp * temp) % mod;
  if (b & 1) temp = (temp * a) % mod;
  return temp;
}
long long pwr(long long a, long long b) {
  if (b == 0) return 1;
  long long temp = pwr(a, b / 2);
  temp = (temp * temp);
  if (b & 1) temp = (temp * a);
  return temp;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return (a / gcd(a, b)) * b; }
long long modularInverse(long long a, long long m) { return pwr(a, m - 2, m); }
bool *isPrime;
void generatePrimeSieve(const int lim) {
  isPrime = (bool *)malloc(lim + 1);
  memset(isPrime, true, lim + 1);
  isPrime[0] = false;
  isPrime[1] = false;
  for (int i = 2; i <= lim; ++i)
    if (isPrime[i])
      for (int j = i + i; j <= lim; j += i) isPrime[j] = false;
}
vector<vector<int> > identityMatrix;
vector<vector<int> > mul(const vector<vector<int> > &a,
                         const vector<vector<int> > &b) {
  int n = a.size();
  vector<vector<int> > ans(n, vector<int>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      for (int k = 0; k < n; ++k) {
        ans[i][j] += ((long long)a[i][k] * b[k][j]) % mod;
        ans[i][j] %= mod;
      }
    }
  }
  return ans;
}
vector<vector<int> > pwr(const vector<vector<int> > &a, long long n) {
  if (n == 0) {
    assert(false);
    return identityMatrix;
  }
  if (n == 1) return a;
  vector<vector<int> > tmp = pwr(a, n / 2);
  tmp = mul(tmp, tmp);
  if (n & 1) tmp = mul(a, tmp);
  return tmp;
}
vector<int> nbrs[100009];
long long DP[100009][2];
int color[100009];
void dfs(int u) {
  if (color[u] == 1) {
    DP[u][0] = 0;
    DP[u][1] = 1;
    for (int i = 0; i < nbrs[u].size(); ++i) {
      int v = nbrs[u][i];
      dfs(v);
      DP[u][1] *= (DP[v][0] + DP[v][1]);
      DP[u][1] %= mod;
    }
  } else {
    DP[u][0] = 1;
    DP[u][1] = 0;
    for (int i = 0; i < nbrs[u].size(); ++i) {
      int v = nbrs[u][i];
      dfs(v);
      DP[u][0] *= (DP[v][0] + DP[v][1]);
      DP[u][0] %= mod;
    }
    long long prod = DP[u][0];
    for (int i = 0; i < nbrs[u].size(); ++i) {
      int v = nbrs[u][i];
      long long addOn = (prod * DP[v][1]) % mod;
      addOn *= modularInverse(DP[v][0] + DP[v][1], mod);
      addOn %= mod;
      DP[u][1] += (addOn);
    }
    DP[u][1] %= mod;
  }
}
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    int x;
    cin >> x;
    nbrs[x].push_back(i + 1);
  }
  for (int i = 0; i < n; ++i) {
    cin >> color[i];
  }
  dfs(0);
  cout << DP[0][1];
}
