#include <bits/stdc++.h>
using namespace std;
const int M = 100005;
long long dp[M][2];
vector<int> G[M];
int color[M];
void dfs(int x) {
  long long ones, zeros;
  ones = color[x];
  zeros = 1 - color[x];
  int u;
  for (int i = 0; i < G[x].size(); i++) {
    u = G[x][i];
    dfs(u);
    ones = (ones * dp[u][1] + ones * dp[u][0] + zeros * dp[u][1]) % 1000000007;
    zeros = (zeros * dp[u][1] + zeros * dp[u][0]) % 1000000007;
  }
  dp[x][1] = ones;
  dp[x][0] = zeros;
}
int main() {
  int n;
  scanf("%d", &n);
  int x;
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &x);
    G[x].push_back(i + 1);
  }
  for (int i = 0; i < n; i++) {
    scanf("%d", &color[i]);
  }
  dfs(0);
  printf("%d\n", dp[0][1]);
  return 0;
}
