#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
const long long mod = 1e9 + 7;
const int maxn = 1e6 + 5;
int n;
vector<int> g[maxn];
int c[maxn];
long long dp[maxn][2];
void dfs(int at) {
  dp[at][c[at]] = 1;
  vector<long long> prefix, suffix;
  long long all = 1;
  for (int to : g[at]) {
    dfs(to);
    prefix.push_back(dp[to][0] + dp[to][1]);
    suffix.push_back(dp[to][0] + dp[to][1]);
    all = all * prefix.back() % mod;
  }
  if (prefix.empty()) return;
  dp[at][c[at]] *= all;
  int len = prefix.size();
  for (int i = 1; i < len; i++) {
    prefix[i] = prefix[i] * prefix[i - 1] % mod;
  }
  for (int i = len - 2; i >= 0; i--) {
    suffix[i] = suffix[i] * suffix[i + 1] % mod;
  }
  if (c[at] == 0) {
    for (int i = 0; i < len; i++) {
      int to = g[at][i];
      dp[at][1] += (i - 1 >= 0 ? prefix[i - 1] : 1) * dp[to][1] % mod *
                   (i + 1 < len ? suffix[i + 1] : 1) % mod;
      dp[at][1] += mod;
    }
  }
  dp[at][0] %= mod;
  dp[at][1] %= mod;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    int p;
    cin >> p;
    g[p].push_back(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  dfs(0);
  long long ans = dp[0][1];
  ans %= mod;
  ans += mod;
  ans %= mod;
  cout << ans << endl;
  return 0;
}
