#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  char i = getchar();
  long long f = 1, res = 0;
  while (i < '0' || i > '9') {
    if (i == '-') f = -1;
    i = getchar();
  }
  while (i >= '0' && i <= '9') {
    res = res * 10 + i - '0';
    i = getchar();
  }
  return res * f;
}
const int N = 1e5 + 50;
const long long mod = 1e9 + 7;
int k, head[N];
long long a[N], dp[N][2];
struct zk {
  int v, next;
} ed[N << 1];
inline void adde(int u, int v) {
  ed[++k].v = v;
  ed[k].next = head[u];
  head[u] = k;
}
inline void dfs(int u, int fa) {
  for (register int i = head[u]; ~i; i = ed[i].next) {
    int v = ed[i].v;
    if (v == fa) continue;
    dfs(v, u);
    dp[u][1] =
        (dp[u][1] * (dp[v][0] + dp[v][1]) % mod + dp[u][0] * dp[v][1] % mod) %
        mod;
    dp[u][0] = (dp[u][0] * (dp[v][0] + dp[v][1])) % mod;
  }
}
int main() {
  memset(head, -1, sizeof head);
  int n = read();
  for (register int i = 2; i <= n; ++i) {
    int p = read() + 1;
    adde(i, p);
    adde(p, i);
  }
  for (register int i = 1; i <= n; ++i) {
    a[i] = read();
    dp[i][a[i]] = 1;
  }
  dfs(1, 0);
  printf("%lld", dp[1][1]);
}
