#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7, N = 1e5 + 5;
int n, c[N], x;
long long dp[N][2];
vector<int> g[N];
void dfs(int v) {
  dp[v][0] = 1LL;
  for (int u : g[v]) {
    dfs(u);
    (dp[u][0] += dp[u][1]) %= mod;
    dp[v][1] = (dp[v][1] * dp[u][0] + dp[v][0] * dp[u][1]) % mod;
    dp[v][0] = (dp[v][0] * dp[u][0]) % mod;
  }
  if (c[v]) {
    dp[v][1] = dp[v][0];
    dp[v][0] = 0;
  }
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 1; i < n; i++) {
    cin >> x;
    g[x].push_back(i);
  }
  for (int i = 0; i < n; i++) cin >> c[i];
  dfs(0);
  cout << dp[0][1];
}
