#include <bits/stdc++.h>
using namespace std;
long long visited[100005] = {false};
vector<int> g[100005];
long long n, x, b[100005], dp[100005][2];
void dfs(int v) {
  dp[v][0] = 1 - b[v];
  dp[v][1] = b[v];
  int old[2];
  for (int i = 0; i < g[v].size(); ++i) {
    int u = g[v][i];
    old[0] = dp[v][0];
    old[1] = dp[v][1];
    dp[v][0] = dp[v][1] = 0;
    dfs(u);
    dp[v][0] = (dp[v][0] + old[0] * dp[u][1]) % 1000000007;
    dp[v][1] = (dp[v][1] + old[1] * dp[u][1]) % 1000000007;
    dp[v][1] = (dp[v][1] + old[0] * dp[u][1]) % 1000000007;
    dp[v][1] = (dp[v][1] + old[1] * dp[u][0]) % 1000000007;
    dp[v][0] = (dp[v][0] + old[0] * dp[u][0]) % 1000000007;
  }
}
int main() {
  cin >> n;
  for (int i = 0; i < n - 1; ++i) {
    cin >> x;
    g[x].push_back(i + 1);
  }
  for (int i = 0; i < n; ++i) cin >> b[i];
  dfs(0);
  cout << dp[0][1] % 1000000007 << endl;
  return 0;
}
