#include <bits/stdc++.h>
using namespace std;
vector<int> adj[200000];
int a[200000];
long long dp[200000][2];
void dfs(int v) {
  dp[v][0] = 1;
  dp[v][1] = 0;
  for (int i = 0; i < adj[v].size(); i++) {
    int u = adj[v][i];
    dfs(u);
    dp[v][1] = (dp[v][1] * dp[u][0]) % 1000000007;
    dp[v][1] = (dp[v][1] + ((dp[v][0] * dp[u][1]) % 1000000007)) % 1000000007;
    dp[v][0] = (dp[v][0] * dp[u][0]) % 1000000007;
  }
  if (a[v] == 1)
    dp[v][1] = dp[v][0];
  else
    dp[v][0] = (dp[v][0] + dp[v][1]) % 1000000007;
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int b;
    scanf(" %d", &b);
    adj[b].push_back(i);
  }
  for (int i = 0; i < n; i++) scanf(" %d", &a[i]);
  dfs(0);
  printf("%d\n", dp[0][1] % 1000000007);
}
