#include <bits/stdc++.h>
std::vector<int> path[300000];
int p[300000];
long long dp[300000][2];
void extended_gcd(long long m, long long n, long long &i, long long &j) {
  if (n == 0) {
    i = 1;
    j = 0;
    return;
  }
  extended_gcd(n, m % n, j, i);
  j = ((j - (m / n) * i) % 1000000007 + 1000000007) % 1000000007;
}
long long verse(long long x) {
  long long i, j;
  extended_gcd(x, 1000000007, i, j);
  return i;
}
void dfs(int x, int f) {
  if (p[x]) {
    dp[x][0] = 0;
    dp[x][1] = 1;
  } else {
    dp[x][0] = 1;
    dp[x][1] = 0;
  }
  for (int i = 0; i < path[x].size(); i++) {
    int to = path[x][i];
    if (to != f) {
      dfs(to, x);
      dp[x][1] = (dp[x][1] * (dp[to][0] + dp[to][1])) % 1000000007;
      dp[x][0] = (dp[x][0] * (dp[to][0] + dp[to][1])) % 1000000007;
    }
  }
  if (p[x] == 0) {
    for (int i = 0; i < path[x].size(); i++) {
      int to = path[x][i];
      if (to != f) {
        dp[x][1] += ((dp[x][0] * dp[to][1]) % 1000000007) *
                    verse(dp[to][0] + dp[to][1]) % 1000000007;
        dp[x][1] %= 1000000007;
      }
    }
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) path[i].clear();
  int x;
  for (int i = 1; i < n; i++) {
    scanf("%d", &x);
    path[x].push_back(i);
    path[i].push_back(x);
  }
  for (int i = 0; i < n; i++) scanf("%d", &p[i]);
  int st = -1;
  for (int i = n - 1; i >= 0; i--)
    if (p[i]) {
      st = i;
      break;
    }
  if (st == -1)
    puts("0");
  else {
    dfs(st, -1);
    printf("%I64d\n", dp[st][1]);
  }
}
