#include <bits/stdc++.h>
using namespace std;
const long long MX = 1e5 + 9, MOD = 1e9 + 7;
long long par[MX], dp[2][MX], col[MX];
vector<long long> adj[MX], pmul[MX], smul[MX];
void DFS(long long u) {
  if (col[u]) {
    dp[0][u] = 0;
    dp[1][u] = 1;
  } else {
    dp[0][u] = 1;
    dp[1][u] = 0;
  }
  if (adj[u].empty()) return;
  for (long long v : adj[u]) {
    DFS(v);
  }
  pmul[u].push_back(1);
  for (long long i = 0; i < adj[u].size(); i++) {
    long long v = adj[u][i];
    pmul[u].push_back((pmul[u].back() * (dp[0][v] + dp[1][v])) % MOD);
  }
  smul[u].push_back(1);
  for (long long i = adj[u].size() - 1; i >= 0; i--) {
    long long v = adj[u][i];
    smul[u].push_back((smul[u].back() * (dp[0][v] + dp[1][v])) % MOD);
  }
  reverse(smul[u].begin(), smul[u].end());
  for (long long i = 0; i < adj[u].size(); i++) {
    long long v = adj[u][i];
    if (col[u]) {
      dp[1][u] *= dp[0][v] + dp[1][v];
      dp[1][u] %= MOD;
    } else {
      dp[0][u] *= dp[0][v] + dp[1][v];
      dp[0][u] %= MOD;
      dp[1][u] += dp[1][v] * ((pmul[u][i] * smul[u][i + 1]) % MOD);
      dp[1][u] %= MOD;
    }
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  cin >> n;
  for (long long i = 1; i < n; i++) {
    cin >> par[i];
    adj[par[i]].push_back(i);
  }
  for (long long i = 0; i < n; i++) cin >> col[i];
  DFS(0);
  cout << dp[1][0];
  return 0;
}
