#include <bits/stdc++.h>
using namespace std;
struct edge {
  int v, next;
} e[400100];
int a[200100], head[200100], tot = 0;
int n;
void Add(int u, int v) {
  e[tot].v = v;
  e[tot].next = head[u];
  head[u] = tot++;
}
long long dp[200100][2];
void DFS(int u, int fa) {
  dp[u][0] = 1;
  dp[u][1] = 0;
  for (int i = head[u]; i != -1; i = e[i].next) {
    int v = e[i].v;
    if (v == fa) continue;
    DFS(v, u);
    dp[u][1] =
        dp[v][0] * dp[u][1] % 1000000007 + dp[v][1] * dp[u][0] % 1000000007;
    dp[u][0] = dp[v][0] * dp[u][0] % 1000000007;
    dp[u][1] %= 1000000007;
  }
  if (a[u] == 0)
    dp[u][0] = (dp[u][1] + dp[u][0]) % 1000000007;
  else
    dp[u][1] = dp[u][0];
}
int main() {
  memset((dp), (0), sizeof(dp));
  memset((head), (-1), sizeof(head));
  scanf("%d", &n);
  for (int i = 1; i < n; i++) {
    int x;
    scanf("%d", &x);
    Add(x, i);
    Add(i, x);
  }
  for (int i = 0; i < n; i++) scanf("%d", &a[i]);
  DFS(0, -1);
  printf("%I64d\n", dp[0][1]);
  return 0;
}
