#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7, N = 1e5 + 5;
vector<int> adj[N], col(N);
long long dp[N][2];
void dfs(int u, int p = 0) {
  dp[u][col[u]] = 1;
  for (auto v : adj[u]) {
    if (v == p) continue;
    dfs(v, u);
    dp[u][1] = (dp[u][0] * dp[v][1] + dp[u][1] * (dp[v][0] + dp[v][1])) % MOD;
    dp[u][0] = (dp[u][0] * (dp[v][0] + dp[v][1])) % MOD;
  }
}
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n - 1; i++) {
    int x;
    cin >> x;
    adj[x].push_back(i + 1);
    adj[i + 1].push_back(x);
  }
  for (int i = 0; i < n; i++) cin >> col[i];
  dfs(0);
  cout << dp[0][1];
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  solve();
}
