#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000 * 100 + 5;
const int MOD = 1000 * 1000 * 1000 + 7;
int n;
vector<int> adj[MAXN];
bool mark[MAXN];
bool black[MAXN];
long long dp[MAXN][2];
void dfs(int v) {
  mark[v] = true;
  vector<long long> a, b;
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i];
    if (mark[u]) continue;
    dfs(u);
    a.push_back(dp[u][0]);
    b.push_back(dp[u][1]);
  }
  if (a.size() == 0) {
    if (black[v]) {
      dp[v][1] = 1;
      dp[v][0] = 1;
    } else {
      dp[v][1] = 0;
      dp[v][0] = 1;
    }
    return;
  }
  vector<long long> t1, t2;
  t1 = a;
  for (int i = 1; i < t1.size(); i++) t1[i] = (t1[i] * t1[i - 1]) % MOD;
  t2 = a;
  for (int i = (int)t2.size() - 2; i >= 0; i--)
    t2[i] = (t2[i] * t2[i + 1]) % MOD;
  if (black[v]) {
    dp[v][1] = t1[t1.size() - 1];
    dp[v][0] = dp[v][1];
  } else {
    dp[v][0] = t1[t1.size() - 1];
    for (int i = 0; i < a.size(); i++) {
      long long add = 1;
      if (i > 0) add = (add * t1[i - 1]) % MOD;
      if (i < a.size() - 1) add = (add * t2[i + 1]) % MOD;
      add = (add * b[i]) % MOD;
      dp[v][1] = (dp[v][1] + add) % MOD;
    }
    dp[v][0] += dp[v][1];
  }
}
int main() {
  cin >> n;
  for (int i = 1; i <= n - 1; i++) {
    int x;
    cin >> x;
    adj[x].push_back(i);
    adj[i].push_back(x);
  }
  for (int i = 0; i < n; i++) cin >> black[i];
  dfs(0);
  cout << dp[0][1] << endl;
  return 0;
}
