#include <bits/stdc++.h>
using namespace std;
long long MOD = 1000000007;
int n;
bool b[100005];
vector<int> g[100005];
long long dp[100005][2];
void solve(int v, int from) {
  dp[v][0] = 1LL;
  dp[v][1] = 0LL;
  for (int i = 0; i < g[v].size(); i++) {
    if (g[v][i] != from) {
      solve(g[v][i], v);
      dp[v][1] = (dp[v][1] * dp[g[v][i]][0]) % MOD;
      dp[v][1] = (dp[v][1] + dp[v][0] * dp[g[v][i]][1]) % MOD;
      dp[v][0] = (dp[v][0] * dp[g[v][i]][0]) % MOD;
    }
  }
  if (b[v])
    dp[v][1] = dp[v][0];
  else
    dp[v][0] += dp[v][1];
}
int main() {
  cin >> n;
  int aux;
  for (int i = 0; i < n - 1; i++) {
    cin >> aux;
    g[i + 1].push_back(aux);
    g[aux].push_back(i + 1);
  }
  for (int i = 0; i < n; i++) cin >> b[i];
  memset(dp, -1, sizeof dp);
  solve(0, 0);
  cout << dp[0][1] << endl;
  return 0;
}
