#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 5;
const long long linf = 1e18 + 5;
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
int n, x, dp[N][2], a[N];
vector<int> v[N];
int f(int x, bool w) {
  int &r = dp[x][w];
  if (r != -1) return r;
  if (a[x]) {
    r = 1;
    for (__typeof((v[x]).begin()) it = (v[x]).begin(); it != (v[x]).end(); it++)
      r = ((long long)r * f(*it, 0)) % mod;
    return r;
  }
  if (v[x].empty()) return r = !w;
  r = 0;
  vector<int> lp, rp;
  lp.resize(v[x].size() + 1);
  rp.resize(v[x].size() + 1);
  lp[0] = 1;
  for (int i = 0; i <= v[x].size() - 1; i++)
    lp[i + 1] = ((long long)lp[i] * f(v[x][i], 0)) % mod;
  rp[v[x].size()] = 1;
  for (int i = v[x].size() - 1; i >= 0; i--)
    rp[i] = ((long long)rp[i + 1] * f(v[x][i], 0)) % mod;
  for (int i = 0; i <= v[x].size() - 1; i++)
    r = (r + (long long)lp[i] * rp[i + 1] % mod * f(v[x][i], 1) % mod) % mod;
  if (!w) {
    int cur = 1;
    for (__typeof((v[x]).begin()) it = (v[x]).begin(); it != (v[x]).end(); it++)
      cur = ((long long)cur * f(*it, 0)) % mod;
    r = (r + cur) % mod;
  }
  return r;
}
int main() {
  ios ::sync_with_stdio(0);
  memset(dp, -1, sizeof(dp));
  cin >> n;
  for (int i = 2; i <= n; i++) {
    cin >> x;
    v[x + 1].push_back(i);
  }
  for (int i = 1; i <= n; i++) cin >> a[i];
  cout << f(1, 1) << '\n';
  return 0;
}
