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