#include <bits/stdc++.h>
using namespace std;
vector<int> tree[100005];
int color[100005];
long long dp_w[100005], dp_b[100005];
long long mod = 1e9 + 7;
void dfs(int curr) {
  dp_b[curr] = color[curr];
  dp_w[curr] = 1 - color[curr];
  vector<long long> lw, rw;
  for (int child : tree[curr]) {
    dfs(child);
    if (color[curr]) {
      dp_b[curr] = (dp_b[curr] * (dp_b[child] + dp_w[child])) % mod;
    } else {
      lw.push_back((dp_b[child] + dp_w[child]) % mod);
      rw.push_back((dp_b[child] + dp_w[child]) % mod);
    }
  }
  for (int i = 1; i < lw.size(); i++) {
    lw[i] = (lw[i] * lw[i - 1]) % mod;
  }
  for (int i = rw.size() - 2; i >= 0; i--) {
    rw[i] = (rw[i] * rw[i + 1]) % mod;
  }
  if (color[curr] == 0) {
    dp_w[curr] = lw.empty() ? 1 : lw.back();
    for (int ci = 0; ci < tree[curr].size(); ci++) {
      int child = tree[curr][ci];
      long long black_from_ci = dp_b[child];
      if (ci) black_from_ci = (black_from_ci * lw[ci - 1]) % mod;
      if (ci < tree[curr].size() - 1)
        black_from_ci = (black_from_ci * rw[ci + 1]) % mod;
      dp_b[curr] += black_from_ci;
      dp_b[curr] %= mod;
    }
  }
}
void solve() {
  int n;
  cin >> n;
  for (int i = 1; i < n; i++) {
    int par;
    cin >> par;
    tree[par].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    int col;
    cin >> col;
    color[i] = col;
  }
  dfs(0);
  cout << dp_b[0] << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  t = 1;
  while (t--) solve();
  return 0;
}
