#include <bits/stdc++.h>
using namespace std;
vector<long long> whs;
vector<long long> bs;
vector<vector<int> > T;
vector<bool> color;
long long m = 1000000007;
void fill_dp(int v) {
  if (T[v].size() == 0) {
    if (color[v]) {
      whs[v] = 0;
      bs[v] = 1;
    } else {
      bs[v] = 0;
      whs[v] = 1;
    }
    return;
  }
  for (int i = 0; i < T[v].size(); i++) {
    fill_dp(T[v][i]);
  }
  if (color[v]) {
    whs[v] = 0;
    bs[v] = 1;
    for (int i = 0; i < T[v].size(); i++) {
      bs[v] = (bs[v] * (bs[T[v][i]] + whs[T[v][i]])) % m;
    }
  } else {
    vector<long long> dp0(T[v].size());
    vector<long long> dp1(T[v].size());
    if (color[T[v][0]]) {
      dp0[0] = bs[T[v][0]];
      dp1[0] = bs[T[v][0]];
      whs[v] = bs[T[v][0]];
    } else {
      dp0[0] = (whs[T[v][0]] + bs[T[v][0]]) % m;
      dp1[0] = bs[T[v][0]];
      whs[v] = (whs[T[v][0]] + bs[T[v][0]]) % m;
    }
    for (int i = 1; i < T[v].size(); i++) {
      if (color[T[v][i]]) {
        whs[v] = (whs[v] * bs[T[v][i]]) % m;
        dp0[i] = (dp0[i - 1] * bs[T[v][i]]) % m;
        dp1[i] = ((dp0[i - 1] + dp1[i - 1]) * bs[T[v][i]]) % m;
      } else {
        whs[v] = (whs[T[v][i]] + bs[T[v][i]]) * whs[v] % m;
        dp0[i] = (dp0[i - 1] * (whs[T[v][i]] + bs[T[v][i]])) % m;
        dp1[i] = (((dp1[i - 1] * (whs[T[v][i]] + bs[T[v][i]])) % m) +
                  ((dp0[i - 1] * bs[T[v][i]]) % m)) %
                 m;
      }
    }
    bs[v] = dp1[T[v].size() - 1];
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  whs.resize(n, 0);
  bs.resize(n, 0);
  T.resize(n);
  color.resize(n);
  for (int i = 0; i < n - 1; i++) {
    int pi;
    cin >> pi;
    T[pi].push_back(i + 1);
  }
  for (int i = 0; i < n; i++) {
    int xi;
    cin >> xi;
    if (xi == 1) {
      color[i] = true;
    } else {
      color[i] = false;
    }
  }
  fill_dp(0);
  cout << bs[0] << "\n";
}
