#include <bits/stdc++.h>
using namespace std;
int mod_inv(int a) {
  int pw = 1000000007 - 2;
  int res = 1;
  while (pw) {
    if (pw & 1) res = 1ll * res * a % 1000000007;
    a = 1ll * a * a % 1000000007;
    pw >>= 1;
  }
  return res;
}
void solver(vector<int> *arr, int n, int id, int prev, int *districts,
            long long **dp) {
  if (districts[id] == 1) {
    dp[id][0] = 0;
    long long prod = 1;
    for (auto &i : arr[id]) {
      if (i != prev) {
        solver(arr, n, i, id, districts, dp);
        prod =
            ((prod % 1000000007) *
             ((dp[i][1] % 1000000007) + (dp[i][0] % 1000000007)) % 1000000007) %
            1000000007;
      }
    }
    dp[id][1] = prod;
    return;
  }
  long long sum = 0;
  long long prod = 1;
  for (auto &i : arr[id]) {
    if (i != prev) {
      solver(arr, n, i, id, districts, dp);
      prod =
          ((prod % 1000000007) *
           ((dp[i][0] % 1000000007) + (dp[i][1] % 1000000007)) % 1000000007) %
          1000000007;
    }
  }
  dp[id][0] = prod;
  for (auto &i : arr[id]) {
    if (i != prev) {
      sum = (sum +
             (1ll * dp[i][1] *
              (1ll * dp[id][0] * mod_inv(dp[i][0] + dp[i][1]) % 1000000007) %
              1000000007)) %
            1000000007;
    }
  }
  dp[id][1] = sum;
  return;
}
int main() {
  int n;
  cin >> n;
  vector<int> *arr = new vector<int>[n];
  for (int i = 0; i < n - 1; i++) {
    int p;
    cin >> p;
    arr[i + 1].push_back(p);
    arr[p].push_back(i + 1);
  }
  int *districts = new int[n];
  int count = 0;
  for (int i = 0; i < n; i++) {
    int b;
    cin >> b;
    count += b;
    districts[i] = b;
  }
  if (count == 0) {
    cout << 0 << endl;
    return 0;
  }
  long long **dp = new long long *[n];
  for (int i = 0; i < n; i++) {
    dp[i] = new long long[2];
  }
  solver(arr, n, 0, -1, districts, dp);
  cout << (dp[0][1] % 1000000007) << endl;
  for (int i = 0; i < n; i++) {
    delete[] dp[i];
  }
  delete[] dp;
  delete[] districts;
  delete[] arr;
  return 0;
}
