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