#include <bits/stdc++.h>
using namespace std;
const long long mod =
    (long long)1000 * (long long)1000 * (long long)1000 + (long long)7;
const int maxn = 1000 * 100 + 5;
int n;
bool a[maxn];
vector<int> w[maxn], q, v[maxn];
vector<long long> p1, p2;
long long dp[maxn], d[maxn];
bool chek[maxn];
void p(int x) {
  long long second = 1;
  p1.clear();
  p2.clear();
  for (int i = 0; i < (int)v[x].size(); i++) {
    p1.push_back(second);
    second *= (d[v[x][i]] + dp[v[x][i]]);
    second %= mod;
  }
  second = 1;
  for (int i = (int)v[x].size() - 1; i >= 0; i--) {
    p2.push_back(second);
    second *= (d[v[x][i]] + dp[v[x][i]]);
    second %= mod;
  }
  reverse(p2.begin(), p2.end());
}
void white(int x) {
  p(x);
  long long second = 1, r = 1;
  for (int i = 0; i < (int)v[x].size(); i++) {
    r *= (dp[v[x][i]] + d[v[x][i]]);
    r %= mod;
    second = dp[v[x][i]];
    second *= p1[i];
    second %= mod;
    second *= p2[i];
    second %= mod;
    dp[x] += second;
    dp[x] %= mod;
  }
  d[x] = r;
}
void black(int x) {
  long long second = 1;
  for (int i = 0; i < (int)v[x].size(); i++) {
    second *= (dp[v[x][i]] + d[v[x][i]]);
    second %= mod;
  }
  dp[x] = second;
  d[x] = 0;
}
void dpp() {
  int x;
  for (int t = 0; t < (int)q.size(); t++) {
    x = q[t];
    if ((int)v[x].size() == 0) {
      if (a[x] == 0) {
        d[x] = 1;
        dp[x] = 0;
      } else {
        d[x] = 0;
        dp[x] = 1;
      }
      continue;
    }
    if (a[x] == 0)
      white(x);
    else
      black(x);
  }
}
void bfs(int x) {
  chek[x] = true;
  q.push_back(x);
  int t = 0;
  while (t < (int)q.size()) {
    x = q[t];
    t++;
    for (int i = 0; i < (int)w[x].size(); i++)
      if (chek[w[x][i]] == false) {
        chek[w[x][i]] = true;
        q.push_back(w[x][i]);
        v[x].push_back(w[x][i]);
      }
  }
}
int main() {
  ios::sync_with_stdio(false);
  int x;
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> x;
    w[i].push_back(x);
    w[x].push_back(i);
  }
  for (int i = 0; i < n; i++) cin >> a[i];
  bfs(0);
  reverse(q.begin(), q.end());
  dpp();
  cout << dp[0] << endl;
  return 0;
}
