#include <bits/stdc++.h>
using namespace std;
vector<int> graph[100000];
bool colour[100000];
long long dp[100000][2];
void dfs(int vertex, int parent) {
  int i, child;
  dp[vertex][1] = colour[vertex];
  dp[vertex][0] = 1 - colour[vertex];
  for (i = 0; i < graph[vertex].size(); i++) {
    child = graph[vertex][i];
    if (child == parent) continue;
    dfs(child, vertex);
    if (colour[vertex]) {
      dp[vertex][1] *= ((dp[child][0] + dp[child][1]) % 1000000007);
      dp[vertex][1] = (dp[vertex][1]) % 1000000007;
    } else {
      dp[vertex][1] *= ((dp[child][0] + dp[child][1]) % 1000000007);
      dp[vertex][1] = (dp[vertex][1]) % 1000000007;
      dp[vertex][1] += ((dp[vertex][0] * dp[child][1]) % 1000000007);
      dp[vertex][1] = (dp[vertex][1]) % 1000000007;
      dp[vertex][0] *= ((dp[child][0] + dp[child][1]) % 1000000007);
      dp[vertex][0] = (dp[vertex][0]) % 1000000007;
    }
  }
}
int main() {
  int n;
  int i;
  int vertex;
  scanf("%d", &n);
  for (i = 1; i < n; i++) {
    scanf("%d", &vertex);
    graph[i].push_back(vertex);
    graph[vertex].push_back(i);
  }
  for (i = 0; i < n; i++) scanf("%d", &colour[i]);
  dfs(0, -1);
  printf("%I64d\n", dp[0][1]);
  return 0;
}
